#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
+1 -1
View File
@@ -8,7 +8,7 @@
"singleItemAutoOpen": true,
"downloadOriginalPhoto": true,
"showGalleryTitle": false,
"allowDownloadAll": false,
"allowDownloadAll": 0,
"showHomePage": true,
"customInvalidResponse": false
},
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "immich-public-proxy",
"version": "1.8.0",
"version": "1.9.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "immich-public-proxy",
"version": "1.8.0",
"version": "1.9.0",
"license": "AGPL-3.0",
"dependencies": {
"archiver": "^7.0.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "immich-public-proxy",
"version": "1.8.0",
"version": "1.9.0",
"scripts": {
"dev": "ts-node src/index.ts",
"build": "npx tsc",
+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
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink, SharedLinkResult } from './types'
import dayjs from 'dayjs'
import { addResponseHeaders, getConfigOption, log } from './functions'
import { addResponseHeaders, canDownload, getConfigOption, log } from './functions'
import render from './render'
import { Response } from 'express-serve-static-core'
import { respondToInvalidRequest } from './invalidRequestHandler'
@@ -105,7 +105,7 @@ class Immich {
// Everything is ok - output the shared link data
if (request.mode === 'download' && getConfigOption('ipp.allowDownloadAll', false)) {
if (request.mode === 'download' && canDownload(link)) {
// Download all assets as a zip file
await render.downloadAll(res, link)
} else if (link.assets.length === 1) {
+2 -2
View File
@@ -1,7 +1,7 @@
import immich from './immich'
import { Response } from 'express-serve-static-core'
import { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink } from './types'
import { getConfigOption } from './functions'
import { canDownload, getConfigOption } from './functions'
import archiver from 'archiver'
import { respondToInvalidRequest } from './invalidRequestHandler'
@@ -121,7 +121,7 @@ class Render {
openItem,
title: this.title(share),
path: '/share/' + share.key,
showDownload: getConfigOption('ipp.allowDownloadAll', false),
showDownload: canDownload(share),
showTitle: getConfigOption('ipp.showGalleryTitle', false),
lgConfig: getConfigOption('lightGallery', {})
})
+7
View File
@@ -20,6 +20,7 @@ export interface SharedLink {
type: string;
description?: string;
assets: Asset[];
allowDownload?: boolean;
password?: string;
album?: {
id: string;
@@ -50,3 +51,9 @@ export interface IncomingShareRequest {
size?: ImageSize;
range?: string;
}
export enum DownloadAll {
disabled,
perImmich,
always
}