From 66a3af69c928f1f4b8741fe04464df8193ffccd7 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Mon, 26 Jan 2026 10:17:48 -0800 Subject: [PATCH] fix: suggested apps breaking (#2343) --- src/backend/src/routers/open_item.js | 8 ++++---- src/backend/src/routers/suggest_apps.js | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/backend/src/routers/open_item.js b/src/backend/src/routers/open_item.js index b4ba072ca..ea7f93ea0 100644 --- a/src/backend/src/routers/open_item.js +++ b/src/backend/src/routers/open_item.js @@ -22,7 +22,7 @@ const FSNodeParam = require('../api/filesystem/FSNodeParam.js'); const { Context } = require('../util/context.js'); const { UserActorType } = require('../services/auth/Actor.js'); const APIError = require('../api/APIError.js'); -const { sign_file, suggest_app_for_fsentry, get_app } = require('../helpers.js'); +const { sign_file, suggestedAppForFsEntry, get_app } = require('../helpers.js'); // -----------------------------------------------------------------------// // POST /open_item @@ -37,7 +37,7 @@ module.exports = eggspress('/open_item', { parameters: { subject: new FSNodeParam('path'), }, -}, async (req, res, next) => { +}, async (req, res) => { const subject = req.values.subject; const actor = Context.get('actor'); @@ -60,13 +60,13 @@ module.exports = eggspress('/open_item', { } const signature = await sign_file(subject.entry, action); - const suggested_apps = await suggest_app_for_fsentry(subject.entry); + const suggested_apps = await suggestedAppForFsEntry(subject.entry); const apps_only_one = suggested_apps.slice(0, 1); const _app = apps_only_one[0]; if ( ! _app ) { throw APIError.create('no_suitable_app', null, { entry_name: subject.entry.name }); } - const app = await get_app(_app.hasOwnProperty('id') + const app = await get_app(Object.prototype.hasOwnProperty.call(_app, 'id') ? { id: _app.id } : { uid: _app.uid }) ?? apps_only_one[0]; diff --git a/src/backend/src/routers/suggest_apps.js b/src/backend/src/routers/suggest_apps.js index 9e1b26a4e..27f53d11e 100644 --- a/src/backend/src/routers/suggest_apps.js +++ b/src/backend/src/routers/suggest_apps.js @@ -23,6 +23,7 @@ const auth = require('../middleware/auth.js'); const config = require('../config'); const { Context } = require('../util/context.js'); const { NodeInternalIDSelector } = require('../filesystem/node/selectors.js'); +const { convert_path_to_fsentry, uuid2fsentry, suggestedAppForFsEntry } = require('../helpers'); // -----------------------------------------------------------------------// // POST /suggest_apps @@ -46,8 +47,6 @@ router.post('/suggest_apps', auth, express.json(), async (req, res, next) => { return res.status(400).send({ message: '`uid` or `path` required' }); } - // modules - const { convert_path_to_fsentry, uuid2fsentry, suggest_app_for_fsentry } = require('../helpers'); let fsentry; // by uid @@ -84,7 +83,7 @@ router.post('/suggest_apps', auth, express.json(), async (req, res, next) => { // get suggestions try { - return res.send(await suggest_app_for_fsentry(fsentry)); + return res.send(await suggestedAppForFsEntry(fsentry)); } catch (e) { return res.status(400).send(e);