#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
|
### Immich Public Proxy options
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Type | Description |
|
||||||
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
|-------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `responseHeaders` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
|
| `responseHeaders` | `object` | 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. |
|
| `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` | Show a title on the gallery page. |
|
| `showGalleryTitle` | `bool` | Show a title on the gallery page. |
|
||||||
| `allowDownloadAll` | Allow visitors to download all files as a zip. |
|
| `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` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
| `showHomePage` | `bool` | 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. |
|
| `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`:
|
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,
|
"singleItemAutoOpen": true,
|
||||||
"downloadOriginalPhoto": true,
|
"downloadOriginalPhoto": true,
|
||||||
"showGalleryTitle": false,
|
"showGalleryTitle": false,
|
||||||
"allowDownloadAll": false,
|
"allowDownloadAll": 0,
|
||||||
"showHomePage": true,
|
"showHomePage": true,
|
||||||
"customInvalidResponse": false
|
"customInvalidResponse": false
|
||||||
},
|
},
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "1.8.0",
|
"version": "1.9.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "1.8.0",
|
"version": "1.9.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "1.8.0",
|
"version": "1.9.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "ts-node src/index.ts",
|
"dev": "ts-node src/index.ts",
|
||||||
"build": "npx tsc",
|
"build": "npx tsc",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { Response } from 'express-serve-static-core'
|
import { Response } from 'express-serve-static-core'
|
||||||
|
import { DownloadAll, SharedLink } from './types'
|
||||||
|
|
||||||
let config = {}
|
let config = {}
|
||||||
try {
|
try {
|
||||||
@@ -46,3 +47,17 @@ export function addResponseHeaders (res: Response) {
|
|||||||
res.set(header, value)
|
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 { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink, SharedLinkResult } from './types'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { addResponseHeaders, getConfigOption, log } from './functions'
|
import { addResponseHeaders, canDownload, getConfigOption, log } from './functions'
|
||||||
import render from './render'
|
import render from './render'
|
||||||
import { Response } from 'express-serve-static-core'
|
import { Response } from 'express-serve-static-core'
|
||||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||||
@@ -105,7 +105,7 @@ class Immich {
|
|||||||
|
|
||||||
// Everything is ok - output the shared link data
|
// 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
|
// Download all assets as a zip file
|
||||||
await render.downloadAll(res, link)
|
await render.downloadAll(res, link)
|
||||||
} else if (link.assets.length === 1) {
|
} else if (link.assets.length === 1) {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
import immich from './immich'
|
import immich from './immich'
|
||||||
import { Response } from 'express-serve-static-core'
|
import { Response } from 'express-serve-static-core'
|
||||||
import { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink } from './types'
|
import { Asset, AssetType, ImageSize, IncomingShareRequest, SharedLink } from './types'
|
||||||
import { getConfigOption } from './functions'
|
import { canDownload, getConfigOption } from './functions'
|
||||||
import archiver from 'archiver'
|
import archiver from 'archiver'
|
||||||
import { respondToInvalidRequest } from './invalidRequestHandler'
|
import { respondToInvalidRequest } from './invalidRequestHandler'
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ class Render {
|
|||||||
openItem,
|
openItem,
|
||||||
title: this.title(share),
|
title: this.title(share),
|
||||||
path: '/share/' + share.key,
|
path: '/share/' + share.key,
|
||||||
showDownload: getConfigOption('ipp.allowDownloadAll', false),
|
showDownload: canDownload(share),
|
||||||
showTitle: getConfigOption('ipp.showGalleryTitle', false),
|
showTitle: getConfigOption('ipp.showGalleryTitle', false),
|
||||||
lgConfig: getConfigOption('lightGallery', {})
|
lgConfig: getConfigOption('lightGallery', {})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export interface SharedLink {
|
|||||||
type: string;
|
type: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
assets: Asset[];
|
assets: Asset[];
|
||||||
|
allowDownload?: boolean;
|
||||||
password?: string;
|
password?: string;
|
||||||
album?: {
|
album?: {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -50,3 +51,9 @@ export interface IncomingShareRequest {
|
|||||||
size?: ImageSize;
|
size?: ImageSize;
|
||||||
range?: string;
|
range?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum DownloadAll {
|
||||||
|
disabled,
|
||||||
|
perImmich,
|
||||||
|
always
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user