#307 Add ipp.upload.notice for a customisable notice on the upload page

This commit is contained in:
Alan Grainger
2026-10-19 14:25:55 +13:00
parent c739e931ea
commit 8bf1d753aa
9 changed files with 47 additions and 18 deletions
+11
View File
@@ -87,6 +87,17 @@ Added to the start of every stored filename: `IMG_0042.jpg` is stored as `ipp_up
what an Immich workflow can match on; see [Tag uploaded photos](/tag-and-review-uploads#tag-uploaded-photos). Set it to `""` what an Immich workflow can match on; see [Tag uploaded photos](/tag-and-review-uploads#tag-uploaded-photos). Set it to `""`
to store the visitor's filename unchanged. to store the visitor's filename unchanged.
### `notice`
**Type:** `string` · **Default:** `"Uploaded photos may not appear in the gallery immediately."`
A short line of text shown below the upload area, letting visitors know their photos won't show up in the gallery
straight away. It's visible the whole time the page is open, so visitors read it before they upload as well as after.
Set it to `""` to hide it.
The text is shown exactly as written, without HTML or links, so you can translate it into your gallery's language. The
reason for the delay is explained in [When do uploads appear](/visitor-uploads#when-do-uploads-appear).
### `notifyUrl` ### `notifyUrl`
**Type:** `string` · **Default:** `""` **Type:** `string` · **Default:** `""`
+3 -1
View File
@@ -319,7 +319,9 @@ The owner sees them in Immich at once. Other visitors see them in the gallery on
3. The visitor's browser has fetched the gallery page again. It keeps the page for 3. The visitor's browser has fetched the gallery page again. It keeps the page for
[`gallery.cacheTime`](/config/gallery#cachetime), 5 minutes by default. [`gallery.cacheTime`](/config/gallery#cachetime), 5 minutes by default.
So a new photo can take up to about 7 minutes to show for a visitor who already had the gallery open. So a new photo can take up to about 7 minutes to show for a visitor who already had the gallery open. The upload page
includes a short notice to let visitors know about the delay; you can change the wording or hide it with the
[`notice`](/config/upload-service#notice) option.
### What happens when a visitor sends a photo the owner already has ### What happens when a visitor sends a photo the owner already has
+1
View File
@@ -7,6 +7,7 @@
"rateLimit": 60, "rateLimit": 60,
"byteBudget": 10240, "byteBudget": 10240,
"filenamePrefix": "ipp_upload_", "filenamePrefix": "ipp_upload_",
"notice": "Uploaded photos may not appear in the gallery immediately.",
"notifyUrl": "", "notifyUrl": "",
"notifyHeaders": {}, "notifyHeaders": {},
"notifyTimeout": 10000 "notifyTimeout": 10000
+10 -10
View File
@@ -71,6 +71,15 @@ html.dark .upload-placeholder:focus-visible {
opacity: 0.7; opacity: 0.7;
} }
/* The owner's notice, from ipp.upload.notice */
.upload-notice {
margin: -8px 0 0;
font-size: 14px;
font-weight: 300;
text-align: center;
opacity: 0.7;
}
/* Nothing to drop on a touch screen */ /* Nothing to drop on a touch screen */
@media (hover: none) { @media (hover: none) {
.upload-drop-hint { .upload-drop-hint {
@@ -97,21 +106,12 @@ html.dark .upload-placeholder:focus-visible {
font-weight: 500; font-weight: 500;
} }
#upload-counts, #upload-counts {
#upload-note {
margin: 0; margin: 0;
font-size: 12px; font-size: 12px;
opacity: 0.8; opacity: 0.8;
} }
#upload-note {
margin-top: 4px;
}
#upload-note[hidden] {
display: none;
}
.upload-count-success { color: var(--color-success); } .upload-count-success { color: var(--color-success); }
.upload-count-danger { color: var(--color-danger); } .upload-count-danger { color: var(--color-danger); }
.upload-count-warning { color: var(--color-warning); } .upload-count-warning { color: var(--color-warning); }
-2
View File
@@ -32,7 +32,6 @@ const run = createLimiter(CONCURRENT_UPLOADS)
const panelEl = document.getElementById('upload-panel') as HTMLElement const panelEl = document.getElementById('upload-panel') as HTMLElement
const progressEl = document.getElementById('upload-progress') as HTMLElement const progressEl = document.getElementById('upload-progress') as HTMLElement
const countsEl = document.getElementById('upload-counts') as HTMLElement const countsEl = document.getElementById('upload-counts') as HTMLElement
const noteEl = document.getElementById('upload-note') as HTMLElement
const listEl = document.getElementById('upload-list') as HTMLElement const listEl = document.getElementById('upload-list') as HTMLElement
const dropEl = document.getElementById('upload-drop') as HTMLElement const dropEl = document.getElementById('upload-drop') as HTMLElement
@@ -72,7 +71,6 @@ function updateSummary () {
uploaded.textContent = String(stats.uploaded) uploaded.textContent = String(stats.uploaded)
errors.textContent = String(stats.errors) errors.textContent = String(stats.errors)
duplicates.textContent = String(stats.duplicates) duplicates.textContent = String(stats.duplicates)
noteEl.hidden = stats.remaining > 0 || stats.uploaded === 0
} }
function setState (row: UploadRow, state: RowState) { function setState (row: UploadRow, state: RowState) {
+6
View File
@@ -32,6 +32,12 @@ export function filenamePrefix (): string {
return typeof configured === 'string' ? configured : '' return typeof configured === 'string' ? configured : ''
} }
/** Text shown under the placeholder on the upload page, from `ipp.upload.notice`. Empty hides it. */
export function uploadNotice (): string {
const configured = getConfigOption('ipp.upload.notice', 'Uploaded photos may not appear in the gallery immediately.')
return typeof configured === 'string' ? configured : ''
}
/** Notification webhook settings from `ipp.upload.notify*`, or undefined when no URL is set. */ /** Notification webhook settings from `ipp.upload.notify*`, or undefined when no URL is set. */
export function notifyConfig (): { url: string, headers: Record<string, string>, timeoutMs: number } | undefined { export function notifyConfig (): { url: string, headers: Record<string, string>, timeoutMs: number } | undefined {
const url = getConfigOption('ipp.upload.notifyUrl', '') const url = getConfigOption('ipp.upload.notifyUrl', '')
+3 -2
View File
@@ -28,7 +28,7 @@ import {
title, title,
unlockHandler unlockHandler
} from '@ipp/core' } from '@ipp/core'
import { galleryUrl, maxFileSize } from './config' import { galleryUrl, maxFileSize, uploadNotice } from './config'
import { uploadAllowed } from './gate' import { uploadAllowed } from './gate'
import { createUploadReceiver } from './receive' import { createUploadReceiver } from './receive'
import { getShare } from './share' import { getShare } from './share'
@@ -142,7 +142,8 @@ router.get('/:shareType(share|s)/:key', decodeCookie, asyncHandler(async (req, r
title: title(resolved.link) title: title(resolved.link)
}, },
basePath: req.baseUrl, basePath: req.baseUrl,
galleryLink: gallery && `${gallery}/${req.params.shareType}/${encodeURIComponent(key)}` galleryLink: gallery && `${gallery}/${req.params.shareType}/${encodeURIComponent(key)}`,
notice: uploadNotice()
}))) })))
})) }))
+4 -2
View File
@@ -9,6 +9,8 @@ export interface UploadPageProps {
basePath: string basePath: string
/** This share's gallery on IPP, when `PUBLIC_BASE_URL` is set. */ /** This share's gallery on IPP, when `PUBLIC_BASE_URL` is set. */
galleryLink?: string galleryLink?: string
/** Plain text shown under the placeholder. Empty hides it. */
notice: string
} }
function Icon ({ path, class: className }: { path: string, class?: string }) { function Icon ({ path, class: className }: { path: string, class?: string }) {
@@ -24,7 +26,7 @@ function Icon ({ path, class: className }: { path: string, class?: string }) {
* gallery's header, a placeholder to click or drop on, and an upload panel * gallery's header, a placeholder to click or drop on, and an upload panel
* the client fills. * the client fills.
*/ */
export function UploadPage ({ config, basePath, galleryLink }: UploadPageProps) { export function UploadPage ({ config, basePath, galleryLink, notice }: UploadPageProps) {
const staticPath = `${basePath}/share/static/${ASSET_VERSION}` const staticPath = `${basePath}/share/static/${ASSET_VERSION}`
return ( return (
<html lang="en"> <html lang="en">
@@ -55,11 +57,11 @@ export function UploadPage ({ config, basePath, galleryLink }: UploadPageProps)
<span class="upload-placeholder-title">Add photos</span> <span class="upload-placeholder-title">Add photos</span>
<span class="upload-placeholder-text">Choose photos and videos<span class="upload-drop-hint">, or drop them here</span></span> <span class="upload-placeholder-text">Choose photos and videos<span class="upload-drop-hint">, or drop them here</span></span>
</button> </button>
{notice && <p class="upload-notice">{notice}</p>}
<input id="upload-input" type="file" multiple accept={UPLOAD_ACCEPT} hidden/> <input id="upload-input" type="file" multiple accept={UPLOAD_ACCEPT} hidden/>
<section id="upload-panel" hidden aria-live="polite" aria-label="Uploads"> <section id="upload-panel" hidden aria-live="polite" aria-label="Uploads">
<p id="upload-progress"></p> <p id="upload-progress"></p>
<p id="upload-counts"></p> <p id="upload-counts"></p>
<p id="upload-note" hidden>New photos appear in the gallery once Immich has processed them.</p>
<ul id="upload-list"></ul> <ul id="upload-list"></ul>
</section> </section>
</main> </main>
+9 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect, afterEach } from 'vitest' import { describe, it, expect, afterEach } from 'vitest'
import { byteBudget, filenamePrefix, maxFileSize, notifyConfig } from '../src/config' import { byteBudget, filenamePrefix, maxFileSize, notifyConfig, uploadNotice } from '../src/config'
import { resetConfig, setConfig } from './helpers' import { resetConfig, setConfig } from './helpers'
afterEach(resetConfig) afterEach(resetConfig)
@@ -12,6 +12,14 @@ describe('upload options', () => {
expect(byteBudget()).toBe(10240 * MB) expect(byteBudget()).toBe(10240 * MB)
expect(filenamePrefix()).toBe('ipp_upload_') expect(filenamePrefix()).toBe('ipp_upload_')
expect(notifyConfig()).toBeUndefined() expect(notifyConfig()).toBeUndefined()
expect(uploadNotice()).toBe('Uploaded photos may not appear in the gallery immediately.')
})
it('shows the owner\'s notice, and hides one that is not a string', () => {
setConfig({ ipp: { upload: { notice: 'Les photos apparaissent plus tard.' } } })
expect(uploadNotice()).toBe('Les photos apparaissent plus tard.')
setConfig({ ipp: { upload: { notice: false } } })
expect(uploadNotice()).toBe('')
}) })
it('never lets maxFileSize reach zero, which would refuse every file', () => { it('never lets maxFileSize reach zero, which would refuse every file', () => {