Refactor to TypeScript ES modules and add metadata sidebar
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { DownloadAll, SharedLink } from './types'
|
||||
import { getConfigOption } from './config/access'
|
||||
|
||||
/**
|
||||
* Display title for a shared link. Prefers the user-set link description,
|
||||
* falls back to the album name (for album shares), or a generic placeholder.
|
||||
* Used by the gallery view-model and as the zip filename in the download
|
||||
* pipeline.
|
||||
*/
|
||||
export function title (share: SharedLink): string {
|
||||
return share.description || share?.album?.albumName || 'Gallery'
|
||||
}
|
||||
|
||||
/**
|
||||
* Decide whether the given shared link is downloadable. The `ipp.allowDownloadAll`
|
||||
* config controls the policy: disabled, follow the per-share Immich setting,
|
||||
* or always allowed.
|
||||
*/
|
||||
export function canDownload (share: SharedLink): boolean {
|
||||
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