From c4236d673741168538741ef084eba6c33441f2de Mon Sep 17 00:00:00 2001 From: Marek Maslowski Date: Fri, 3 Apr 2026 03:29:13 +0200 Subject: [PATCH] fixing path for asset in full res --- server/src/routes/synology.ts | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/server/src/routes/synology.ts b/server/src/routes/synology.ts index c1e868e..7312eaa 100644 --- a/server/src/routes/synology.ts +++ b/server/src/routes/synology.ts @@ -528,7 +528,7 @@ router.get('/assets/:photoId/thumbnail', authFromQuery, async (req: Request, res const authReq = req as AuthRequest; const { photoId } = req.params; const parsedId = splitPackedSynologyId(photoId); - const { userId, cacheKey, size = 'sm' } = req.query; + const { userId, size = 'sm' } = req.query; const targetUserId = userId ? Number(userId) : authReq.user.id; @@ -543,29 +543,15 @@ router.get('/assets/:photoId/thumbnail', authFromQuery, async (req: Request, res return res.status(401).send('Authentication failed'); } - let resolvedCacheKey = cacheKey ? String(cacheKey) : parsedId.cacheKey; - if (!resolvedCacheKey) { - const row = db.prepare(` - SELECT asset_id FROM trip_photos - WHERE user_id = ? AND (asset_id = ? OR asset_id = ? OR asset_id LIKE ? OR asset_id LIKE ?) - ORDER BY id DESC LIMIT 1 - `).get(targetUserId, parsedId.assetId, parsedId.id, `${parsedId.id}_%`, `${parsedId.id}::%`) as { asset_id?: string } | undefined; - const packed = row?.asset_id || ''; - if (packed) { - resolvedCacheKey = splitPackedSynologyId(packed).cacheKey; - } - } - if (!resolvedCacheKey) return res.status(404).send('Missing cache key for thumbnail'); - const params = new URLSearchParams({ api: 'SYNO.Foto.Thumbnail', method: 'get', version: '2', mode: 'download', - id: String(parsedId.id), + id: parsedId.id, type: 'unit', size: String(size), - cache_key: resolvedCacheKey, + cache_key: parsedId.cacheKey, _sid: sid.sid, }); const url = prepareSynologyEndpoint(creds.synology_url) + '?' + params.toString(); @@ -596,9 +582,11 @@ router.get('/assets/:photoId/thumbnail', authFromQuery, async (req: Request, res }); -router.get('/assets/download', authFromQuery, async (req: Request, res: Response) => { +router.get('/assets/:photoId/original', authFromQuery, async (req: Request, res: Response) => { const authReq = req as AuthRequest; - const { userId, cacheKey, unitIds } = req.query; + const { photoId } = req.params; + const parsedId = splitPackedSynologyId(photoId || ''); + const { userId} = req.query; const targetUserId = userId ? Number(userId) : authReq.user.id; @@ -617,8 +605,8 @@ router.get('/assets/download', authFromQuery, async (req: Request, res: Response api: 'SYNO.Foto.Download', method: 'download', version: '2', - cache_key: String(cacheKey), - unit_id: "[" + String(unitIds) + "]", + cache_key: parsedId.cacheKey, + unit_id: `[${parsedId.id}]`, _sid: sid.sid, });