#76 add option to follow Immich per-link download settings
This commit is contained in:
@@ -140,14 +140,14 @@ There are some additional configuration options you can change, for example the
|
||||
|
||||
### Immich Public Proxy options
|
||||
|
||||
| Option | Description |
|
||||
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||
| `responseHeaders` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
|
||||
| `downloadOriginalPhoto` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
|
||||
| `showGalleryTitle` | Show a title on the gallery page. |
|
||||
| `allowDownloadAll` | Allow visitors to download all files as a zip. |
|
||||
| `showHomePage` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
||||
| `customInvalidResponse` | Send a custom response instead of the default 404 - see [Custom responses](docs/custom-responses.md) for more details. |
|
||||
| Option | Type | Description |
|
||||
|-------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
|
||||
| `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
|
||||
| `showGalleryTitle` | `bool` | Show a title on the gallery page. |
|
||||
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share<br>`2` always allowed |
|
||||
| `showHomePage` | `bool` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
||||
| `customInvalidResponse` | various | Send a custom response instead of the default 404 - see [Custom responses](docs/custom-responses.md) for more details. |
|
||||
|
||||
For example, to disable the home page at `/` and at `/share` you need to change `showHomePage` to `false`:
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
"singleItemAutoOpen": true,
|
||||
"downloadOriginalPhoto": true,
|
||||
"showGalleryTitle": false,
|
||||
"allowDownloadAll": false,
|
||||
"allowDownloadAll": 0,
|
||||
"showHomePage": true,
|
||||
"customInvalidResponse": false
|
||||
},
|
||||
|
||||
Generated
+2
-2
@@ -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
@@ -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",
|
||||
|
||||
@@ -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
@@ -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
@@ -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', {})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user