Skip to content

Commit 7b38131

Browse files
committed
fix: desktop_items in whoami
There's a potential issue here because of an undefined reference, but I can't seem to reproduce any problem caused by this. However without this fix this line of code is guarenteed to throw an exception so this fix should be safe.
1 parent c4b5b48 commit 7b38131

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

extensions/whoami/routes.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// static imports
22
import TimeAgo from 'javascript-time-ago';
33
import localeEn from 'javascript-time-ago/locale/en';
4+
import _path from 'fs';
45

56
// runtime imports
67
const { UserActorType, AppUnderUserActorType } = extension.import('core');
@@ -92,9 +93,9 @@ extension.get('/whoami', { subdomain: 'api' }, async (req, res, next) => {
9293
: { no_icons: true }),
9394
}),
9495
referral_code: req.user.referral_code,
95-
otp: !! req.user.otp_enabled,
96+
otp: !!req.user.otp_enabled,
9697
human_readable_age: timeago.format(new Date(req.user.timestamp)),
97-
hasDevAccountAccess: !! req.actor.type.user.metadata?.hasDevAccountAccess,
98+
hasDevAccountAccess: !!req.actor.type.user.metadata?.hasDevAccountAccess,
9899
...(req.new_token ? { token: req.token } : {}),
99100
};
100101

@@ -160,7 +161,7 @@ extension.post('/whoami', { subdomain: 'api' }, async (req, res) => {
160161
}
161162
// by desktop path
162163
else {
163-
desktop_items = await get_descendants(req.user.username + '/Desktop', req.user, 1, true);
164+
desktop_items = await get_descendants(`${req.user.username }/Desktop`, req.user, 1, true);
164165
}
165166

166167
// clean up desktop items and add some extra information
@@ -169,11 +170,11 @@ extension.post('/whoami', { subdomain: 'api' }, async (req, res) => {
169170
for ( let i = 0; i < desktop_items.length; i++ ) {
170171
if ( desktop_items[i].id !== null ) {
171172
// suggested_apps for files
172-
if ( !desktop_items[i].is_dir ) {
173+
if ( ! desktop_items[i].is_dir ) {
173174
desktop_items[i].suggested_apps = await suggest_app_for_fsentry(desktop_items[i], { user: req.user });
174175
}
175176
// is_shared
176-
desktop_items[i].is_shared = await is_shared_with_anyone(desktop_items[i].id);
177+
desktop_items[i].is_shared = await is_shared_with_anyone(desktop_items[i].id);
177178

178179
// associated_app
179180
if ( desktop_items[i].associated_app_id ) {
@@ -220,6 +221,6 @@ extension.post('/whoami', { subdomain: 'api' }, async (req, res) => {
220221
taskbar_items: await get_taskbar_items(req.user),
221222
desktop_items: desktop_items,
222223
referral_code: req.user.referral_code,
223-
hasDevAccountAccess: !! req.actor.user.metadata?.hasDevAccountAccess,
224+
hasDevAccountAccess: !!req.actor.user.metadata?.hasDevAccountAccess,
224225
}, whoami_common({ is_user, user: req.user })));
225226
});

0 commit comments

Comments
 (0)