Skip to content

Commit 9751fd9

Browse files
committed
feat: add appdata permission (if applicable) on app share
1 parent 13e2f72 commit 9751fd9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/backend/src/routers/share.js

+21
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ const v0_2 = async (req, res) => {
427427
: { id: { name: thing.name } }
428428
});
429429
}
430+
431+
app.metadata = db.case({
432+
mysql: () => app.metadata,
433+
otherwise: () => JSON.parse(app.metadata ?? '{}')
434+
})();
435+
430436
item.app = app;
431437
}
432438

@@ -451,6 +457,21 @@ const v0_2 = async (req, res) => {
451457
)
452458
}
453459

460+
// Process: conditionally add permission for AppData
461+
for ( const item of shares_work.list() ) {
462+
if ( item.type !== 'app' ) continue;
463+
if ( ! item.app.metadata?.shared_appdata ) continue;
464+
465+
const app_owner = await get_user({ id: item.app.owner_user_id });
466+
467+
const appdatadir =
468+
`/${app_owner.username}/AppData/${item.app.uid}`;
469+
const appdatadir_perm =
470+
PermissionUtil.join('fs', appdatadir, 'write');
471+
472+
item.share_intent.permissions.push(appdatadir_perm);
473+
}
474+
454475
shares_work.clear_invalid();
455476

456477
// Mark files as successful; further errors will be

0 commit comments

Comments
 (0)