#76 add option to follow Immich per-link download settings

This commit is contained in:
Alan Grainger
2025-03-12 15:26:46 +08:00
parent c4f62ed818
commit 0bbe409cbb
8 changed files with 38 additions and 16 deletions
+15
View File
@@ -1,5 +1,6 @@
import dayjs from 'dayjs'
import { Response } from 'express-serve-static-core'
import { DownloadAll, SharedLink } from './types'
let config = {}
try {
@@ -46,3 +47,17 @@ export function addResponseHeaders (res: Response) {
res.set(header, value)
})
}
export function canDownload (share: SharedLink) {
const allowDownloadConfig = getConfigOption('ipp.allowDownloadAll', 0) as DownloadAll
if (!allowDownloadConfig) {
// Downloading is disabled in config.json
return false
} else if (allowDownloadConfig === DownloadAll.always) {
// Always allowed to download in config.json
return true
} else {
// Return Immich's setting for this shared link
return !!share.allowDownload
}
}