feat: add appdata permission (if applicable) on app share

This commit is contained in:
KernelDeimos 2024-06-24 18:56:39 -04:00 committed by Eric Dubé
parent 13e2f72c9f
commit 9751fd92a5

View File

@ -427,6 +427,12 @@ const v0_2 = async (req, res) => {
: { id: { name: thing.name } }
});
}
app.metadata = db.case({
mysql: () => app.metadata,
otherwise: () => JSON.parse(app.metadata ?? '{}')
})();
item.app = app;
}
@ -451,6 +457,21 @@ const v0_2 = async (req, res) => {
)
}
// Process: conditionally add permission for AppData
for ( const item of shares_work.list() ) {
if ( item.type !== 'app' ) continue;
if ( ! item.app.metadata?.shared_appdata ) continue;
const app_owner = await get_user({ id: item.app.owner_user_id });
const appdatadir =
`/${app_owner.username}/AppData/${item.app.uid}`;
const appdatadir_perm =
PermissionUtil.join('fs', appdatadir, 'write');
item.share_intent.permissions.push(appdatadir_perm);
}
shares_work.clear_invalid();
// Mark files as successful; further errors will be