diff --git a/src/backend/src/routers/open_item.js b/src/backend/src/routers/open_item.js index 1220d5aa6..ce7e2cb89 100644 --- a/src/backend/src/routers/open_item.js +++ b/src/backend/src/routers/open_item.js @@ -84,11 +84,14 @@ module.exports = eggspress('/open_item', { // Note: We always grant write permission here. If the user only // has read permission this is still safe; user permissions // are always checked during an app access. - const permission = `fs:${subject.uid}:write`; - const svc_permission = Context.get('services').get('permission'); - await svc_permission.grant_user_app_permission( - actor, app.uid, permission, {}, { reason: 'open_item' } - ); + const PERMS = action === 'write' ? ['read', 'write'] : ['read']; + for ( const perm of PERMS ) { + const permission = `fs:${subject.uid}:${perm}`; + const svc_permission = Context.get('services').get('permission'); + await svc_permission.grant_user_app_permission( + actor, app.uid, permission, {}, { reason: 'open_item' } + ); + } // Generate user-app token const svc_auth = Context.get('services').get('auth'); diff --git a/src/gui/src/UI/UIDesktop.js b/src/gui/src/UI/UIDesktop.js index cc724ed55..963fff321 100644 --- a/src/gui/src/UI/UIDesktop.js +++ b/src/gui/src/UI/UIDesktop.js @@ -166,9 +166,9 @@ async function UIDesktop(options){ window.socket.on('notif.message', async ({ uid, notification }) => { let icon = window.icons[notification.icon]; let round_icon = false; - + if(notification.template === "file-shared-with-you" && notification.fields?.username){ - let profile_pic = await get_profile_picture(notification.fields.username); + let profile_pic = await get_profile_picture(notification.fields?.username); if(profile_pic){ icon = profile_pic; round_icon = true; @@ -208,16 +208,26 @@ async function UIDesktop(options){ }); window.__already_got_unreads = false; - window.socket.on('notif.unreads', ({ unreads }) => { + window.socket.on('notif.unreads', async ({ unreads }) => { if ( window.__already_got_unreads ) return; window.__already_got_unreads = true; for ( const notif_info of unreads ) { const notification = notif_info.notification; - const icon = window.icons[notification.icon]; - + let icon = window.icons[notification.icon]; + let round_icon = false; + + if(notification.template === "file-shared-with-you" && notification.fields?.username){ + let profile_pic = await get_profile_picture(notification.fields?.username); + if(profile_pic){ + icon = profile_pic; + round_icon = true; + } + } + UINotification({ icon, + round_icon, title: notification.title, text: notification.text ?? notification.title, uid: notif_info.uid, @@ -233,6 +243,18 @@ async function UIDesktop(options){ }), }); }, + click: async (notif) => { + if(notification.template === "file-shared-with-you"){ + let item_path = '/' + notification.fields?.username; + UIWindow({ + path: '/' + notification.fields?.username, + title: path.basename(item_path), + icon: await item_icon({is_dir: true, path: item_path}), + is_dir: true, + app: 'explorer', + }); + } + }, }); } }); @@ -1282,7 +1304,33 @@ async function UIDesktop(options){ .then(response => response.json()) .then(data => { if(data && data.result && data.result.length > 0){ - data.data?.forEach(notification => { + data.data?.forEach(async notification => { + let icon = window.icons['puter-logo.svg']; + let round_icon = false; + + if(notification.template === "file-shared-with-you" && notification.fields?.username){ + let profile_pic = await get_profile_picture(notification.fields?.username); + if(profile_pic){ + icon = profile_pic; + round_icon = true; + notification.round_icon = round_icon; + } + } + notification.icon = icon; + + notification.click = async (notif) => { + if(notification.template === "file-shared-with-you"){ + let item_path = '/' + notification.fields?.username; + UIWindow({ + path: '/' + notification.fields?.username, + title: path.basename(item_path), + icon: await item_icon({is_dir: true, path: item_path}), + is_dir: true, + app: 'explorer', + }); + } + } + UINotification(notification); }) } diff --git a/src/gui/src/i18n/translations/br.js b/src/gui/src/i18n/translations/br.js index 776e0ddf2..310475bc0 100644 --- a/src/gui/src/i18n/translations/br.js +++ b/src/gui/src/i18n/translations/br.js @@ -347,23 +347,20 @@ const br = { "login2fa_recovery_back": "Voltar", "login2fa_recovery_placeholder": "XXXXXXXX", - // *********************************** - // Missing translations - // *********************************** - "change": undefined, // In English: "Change" - "clock_visibility": undefined, // In English: "Clock Visibility" - "reading": undefined, // In English: "Reading %strong%" - "writing": undefined, // In English: "Writing %strong%" - "unzipping": undefined, // In English: "Unzipping %strong%" - "sequencing": undefined, // In English: "Sequencing %strong%" - "zipping": undefined, // In English: "Zipping %strong%" - "Editor": undefined, // In English: "Editor" - "Viewer": undefined, // In English: "Viewer" - "People with access": undefined, // In English: "People with access" - "Share With…": undefined, // In English: "Share With…" - "Owner": undefined, // In English: "Owner" - "You can't share with yourself.": undefined, // In English: "You can't share with yourself." - "This user already has access to this item": undefined, // In English: "This user already has access to this item" + "change": "Alterar", // In English: "Change" + "clock_visibility": "Visibilidade do relógio", // In English: "Clock Visibility" + "reading": "Lendo %strong%", // In English: "Reading %strong%" + "writing": "Escrevendo %strong%", // In English: "Writing %strong%" + "unzipping": "Descompactando %strong%", // In English: "Unzipping %strong%" + "sequencing": "Sequenciando %strong%", // In English: "Sequencing %strong%" + "zipping": "Compactando %strong%", // In English: "Zipping %strong%" + "Editor": "Editor", // In English: "Editor" + "Viewer": "Visualizador", // In English: "Viewer" + "People with access": "Pessoas com acesso", // In English: "People with access" + "Share With…": "Compartilhar com...", // In English: "Share With…" + "Owner": "Proprietário", // In English: "Owner" + "You can't share with yourself.": "Vocẽ não pode compartilhar com você mesmo", // In English: "You can't share with yourself." + "This user already has access to this item": "Esse usuário já tem acesso a esse item", // In English: "This user already has access to this item" } }; diff --git a/src/gui/src/i18n/translations/vi.js b/src/gui/src/i18n/translations/vi.js index 759b9ecf3..bf132e03c 100644 --- a/src/gui/src/i18n/translations/vi.js +++ b/src/gui/src/i18n/translations/vi.js @@ -347,25 +347,22 @@ const vi = { login2fa_recovery_back: 'Quay lại', login2fa_recovery_placeholder: 'XXXXXXXX', - // *********************************** - // Missing translations - // *********************************** - "change": undefined, // In English: "Change" - "clock_visibility": undefined, // In English: "Clock Visibility" - "plural_suffix": undefined, // In English: "s" - "reading": undefined, // In English: "Reading %strong%" - "writing": undefined, // In English: "Writing %strong%" - "unzipping": undefined, // In English: "Unzipping %strong%" - "sequencing": undefined, // In English: "Sequencing %strong%" - "zipping": undefined, // In English: "Zipping %strong%" - "Editor": undefined, // In English: "Editor" - "Viewer": undefined, // In English: "Viewer" - "People with access": undefined, // In English: "People with access" - "Share With…": undefined, // In English: "Share With…" - "Owner": undefined, // In English: "Owner" - "You can't share with yourself.": undefined, // In English: "You can't share with yourself." - "This user already has access to this item": undefined, // In English: "This user already has access to this item" + "change": 'Thay đổi', // In English: "Change" + "clock_visibility": 'ẩn/hiện đồng hồ', // In English: "Clock Visibility" + "plural_suffix": 'các', // In English: "s" + "reading": 'Đang đọc %strong%', // In English: "Reading %strong%" + "writing": 'Đang ghi dữ liệu %strong%', // In English: "Writing %strong%" + "unzipping": 'Đang giải nén %strong%', // In English: "Unzipping %strong%" + "sequencing": 'Đang đánh thứ tự %strong%', // In English: "Sequencing %strong%" + "zipping": 'Đang nén %strong%', // In English: "Zipping %strong%" + "Editor": 'Người chỉnh sửa', // In English: "Editor" + "Viewer": 'Người xem', // In English: "Viewer" + "People with access": 'Người dùng có quyền truy cập', // In English: "People with access" + "Share With…": 'Chia sẻ với...', // In English: "Share With…" + "Owner": 'Người sở hữu', // In English: "Owner" + "You can't share with yourself.": 'Bạn không thể tự chia sẻ với chính mình', // In English: "You can't share with yourself." + "This user already has access to this item": 'Người dùng này đã có sẵn quyền truy cập cho mục này', // In English: "This user already has access to this item" } }; -export default vi; \ No newline at end of file +export default vi; diff --git a/src/gui/src/i18n/translations/zhtw.js b/src/gui/src/i18n/translations/zhtw.js index bec81cd7d..5fdda1b37 100644 --- a/src/gui/src/i18n/translations/zhtw.js +++ b/src/gui/src/i18n/translations/zhtw.js @@ -346,23 +346,20 @@ const zhtw = { login2fa_recovery_back: '返回', login2fa_recovery_placeholder: 'XXXXXXXX', - // *********************************** - // Missing translations - // *********************************** - "change": undefined, // In English: "Change" - "clock_visibility": undefined, // In English: "Clock Visibility" - "reading": undefined, // In English: "Reading %strong%" - "writing": undefined, // In English: "Writing %strong%" - "unzipping": undefined, // In English: "Unzipping %strong%" - "sequencing": undefined, // In English: "Sequencing %strong%" - "zipping": undefined, // In English: "Zipping %strong%" - "Editor": undefined, // In English: "Editor" - "Viewer": undefined, // In English: "Viewer" - "People with access": undefined, // In English: "People with access" - "Share With…": undefined, // In English: "Share With…" - "Owner": undefined, // In English: "Owner" - "You can't share with yourself.": undefined, // In English: "You can't share with yourself." - "This user already has access to this item": undefined, // In English: "This user already has access to this item" + "change": '更改', // In English: "Change" + "clock_visibility": '時鐘可視性', // In English: "Clock Visibility" + "reading": '正在讀取 %strong%', // In English: "Reading %strong%" + "writing": '正在寫入 %strong%', // In English: "Writing %strong%" + "unzipping": '正在解壓 %strong%', // In English: "Unzipping %strong%" + "sequencing": '正在排序 %strong%', // In English: "Sequencing %strong%" + "zipping": '正在壓縮 %strong%', // In English: "Zipping %strong%" + "Editor": '編輯器', // In English: "Editor" + "Viewer": '檢視者', // In English: "Viewer" + "People with access": '有權限的人', // In English: "People with access" + "Share With…": '分享給……', // In English: "Share With…" + "Owner": '所有者', // In English: "Owner" + "You can't share with yourself.": '您不能與自己分享。', // In English: "You can't share with yourself." + "This user already has access to this item": '該用戶已有訪問此項的權限', // In English: "This user already has access to this item" } };