Fix #230 slug album not downloading correctly

This commit is contained in:
Alan Grainger
2026-05-28 09:35:03 +08:00
parent 062c7bef19
commit 95957b7d37
3 changed files with 28 additions and 20 deletions
+10 -8
View File
@@ -200,23 +200,25 @@ app.get('/share/:type(photo|video)/:key/:id/:size?', decodeCookie, async (req, r
return
}
// Verify the requested asset belongs to this share link
const assetBelongsToShare = share.link?.assets?.some(a => a.id === req.params.id)
if (!assetBelongsToShare) {
// Find the real asset on the share so assetBuffer has access to
// originalMimeType and originalFileName (needed for Content-Disposition and
// for requiresOriginal to recognise videos/animated images and bypass the
// preview downgrade). Doubles as the "belongs to this share" check.
const realAsset = share.link?.assets?.find(a => a.id === req.params.id)
if (!realAsset) {
respondToInvalidRequest(res, 404, 'Asset not found in share')
return
}
const asset: Asset = {
...realAsset,
type: req.params.type === 'video' ? AssetType.video : AssetType.image
}
const request = {
req,
key: req.params.key,
range: req.headers.range || ''
}
const asset = {
id: req.params.id,
key: req.params.key,
type: req.params.type === 'video' ? AssetType.video : AssetType.image
} as Asset
render.assetBuffer(request, res, asset, req.params.size).then()
})