#76 add option to follow Immich per-link download settings
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user