Add the optional Immich integration and manual gallery push

Immich connections stay server-side with an encrypted API key, albums can be
imported, and photos are only sent back when an event's push button is pressed:
originals upload once, edited photos re-render, and edits hashes plus checksums
skip anything already in Immich. This also lands the accompanying editor, cloud
and administration work that was still uncommitted.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-25 17:43:05 +00:00
parent e0c76ba965
commit 0b3ab76405
26 changed files with 4323 additions and 144 deletions
+117 -4
View File
@@ -199,6 +199,8 @@ storage, while quotas are stored per account in the database.
| `PORT` | `8787` | HTTP port (**not** prefixed with `LUMINARY_`) |
| `HOST` | `0.0.0.0` | Bind address (**not** prefixed) |
| `LUMINARY_DATA` | `server/data` | Where the database and image folders live |
| `LUMINARY_SECRET_KEY` | *(auto)* | Key for encrypting the saved SMTP password and bridge service tokens; when empty, a generated key is kept in `<data>/secret.key` — back it up with the database |
| `LUMINARY_TRUST_PROXY` | *(empty)* | Set to `1` only behind a proxy that overwrites `X-Forwarded-For`; makes login limits and `Secure` cookie detection use the real client address |
| `LUMINARY_INVITE` | *(empty)* | Shared registration code for teammates; personal invite links work without it |
| `LUMINARY_MAX_UPLOAD` | `314572800` (300 MB) | Largest accepted upload, in bytes |
| `LUMINARY_RAW_EDGE` | `6000` | Long edge of the editable JPEG proxy made from a raw |
@@ -230,6 +232,15 @@ directly and have no legacy alias.
per-user salt and a 64-byte derived key.
- The session cookie is named `lumen_session` and is `HttpOnly; SameSite=Lax`. It is
marked `Secure` only when the request arrives with `X-Forwarded-Proto: https`.
- Responses carry `X-Content-Type-Options: nosniff` and a self-only CSP, and stored
photo MIME types are limited to raster images. A member cannot make a gallery link
serve HTML or SVG, even by uploading a file with that content.
- Sign-in is throttled per account and address (8 failures per account per 15 minutes;
50 per client address, or 500 when a proxy's address is shared). Set
`LUMINARY_TRUST_PROXY=1` behind a proxy so `X-Forwarded-For` identifies the caller.
Gallery writes are limited to 120 per minute per link.
- Uploads are streamed to disk and charged to the uploader's quota before their catalog
row exists, so an interrupted import cannot leave unbilled files behind.
- There is no TLS in the server. Terminate HTTPS at a reverse proxy.
- The SQLite file, the IndexedDB database and the Compose volume all keep the
`lumenroom` name so older deployments upgrade in place.
@@ -299,7 +310,9 @@ Two independent things to back up:
1. **The catalog plus originals** — copy the whole data directory (or the Docker
volume). Stop the server, or accept that SQLite is in WAL mode and copy
`lumenroom.db`, `lumenroom.db-wal` and `lumenroom.db-shm` together.
`lumenroom.db`, `lumenroom.db-wal` and `lumenroom.db-shm` together. Keep
`secret.key` with it (unless `LUMINARY_SECRET_KEY` is set): without it the saved
SMTP password and bridge tokens cannot be decrypted.
2. **A logical catalog export** — an admin can download a JSON backup (events, photo
records, presets and key/value settings) from the admin panel, or via
`GET /api/admin/catalog`, and restore it with `POST /api/admin/catalog`. This does
@@ -439,7 +452,7 @@ SQLite is created and migrated at boot. All statements are prepared once in `db.
| `gallery_comments` | per-token client comments with author name and timestamp |
| `gallery_reviews` | per-token, per-photo, per-client approved / changes status |
| `invites` | token, optional email lock, role, expiry, acceptance and revocation |
| `bridge_events` | imported event id, dashboard session, encrypted-at-rest token, TTL |
| `bridge_events` | imported event id, dashboard session, AES-GCM-sealed service token, TTL |
| `user_quota` | limit, scheduled prune time/plan, last warning timestamps |
Photo and event records are JSON documents with a few extracted columns for ordering,
@@ -524,7 +537,7 @@ routes are public and are gated only by the share token.
| GET | `/api/galleries/:token/photos/:id/thumb` | public | Gallery thumbnail |
| GET | `/api/galleries/:token/photos/:id/preview` | public | Gallery preview |
| GET | `/api/galleries/:token/photos/:id/download` | public | Download one proof |
| GET | `/api/galleries/:token/download-all?client=` | public | ZIP of the event's proofs, generated in-stream |
| GET | `/api/galleries/:token/download-all?client=` | public | ZIP of the event's proofs; at most 400 files / 512 MB, one archive at a time |
| POST | `/api/galleries/:token/picks` | public | Add or remove a client favourite |
| POST | `/api/galleries/:token/comments` | public | Append a client comment |
| POST | `/api/galleries/:token/reviews` | public | Set approved / changes / none |
@@ -665,6 +678,106 @@ Empty `GLENLOCH_URL` or `BRIDGE_SECRET` disables the bridge entirely.
---
## Immich album sync
Immich support is optional. An administrator can configure one server-wide connection, and
nothing appears in the app for accounts until that connection is enabled. Per-account
connections are still supported as a fallback when no shared connection exists.
Open **Administration → Immich** as an administrator:
1. Enter your Immich server address and an API key from Account Settings → API Keys.
The key is sealed with AES-256-GCM, stays on the server, and is never returned by the
API — the browser only ever sees `hasKey`. Back up `LUMINARY_SECRET_KEY` (or the
generated `<data>/secret.key`) with the database.
2. Leave **Automatically publish event photos and edits** on and **Test connection**.
3. Users can then **Refresh albums** in the per-account Immich panel and import one.
Imports run as a background job with progress.
Required key permissions: `album.read`, `album.create`, `albumAsset.create`, `asset.read`,
`asset.download`, `asset.upload` and `asset.update`. Add `tag.read`, `tag.create` and
`tag.asset` for keyword sync. Add `asset.delete` only if you intend to move originals to
the Immich trash after an edit is uploaded.
### Pull
- Streams each image to disk; raws use the normal LibRaw pipeline, so the editable proxy
matches an upload exactly.
- One Luminary event per album, reused on every sync. Every source asset is recorded in
`immich_assets`, so a re-import adds only missing photos and never duplicates one.
- Capture date and basic EXIF (camera, lens, ISO, aperture, shutter, focal length) are
carried across. Ratings, flags, edits and keywords stay Luminary-side.
- Formats the browser cannot display (for example HEIC) keep their original bytes and get
a server-rendered JPEG proxy.
- Uses the account storage quota; a full quota stops the job with a message.
### Event galleries
When importing into an event, Luminary creates a matching Immich album by default, links
it to the event, and makes that album the destination for originals and edits. The checkbox
in the import dialog can turn this off for one import. Unlike an imported album, a gallery
is never re-imported and is skipped by scheduled sync, so the versions uploaded from
Luminary do not come back as new photos.
Every successful import into an event with a gallery is added automatically: the server
uploads each original (converting non-JPEG and raw files to JPEG) and the existing checksum
record prevents a retry from uploading the same file twice. Import failures are reported per
photo and do not stop the rest of the set.
### Push back
Edits are saved automatically after you stop adjusting a photo: Luminary waits briefly,
renders the current edit at full resolution as a JPEG, uploads it to the event's Immich album,
and uses the checksum record to skip an unchanged render. You can still use **Send edit to
Immich** from the context menu to send immediately. Luminary:
1. Uploads it as a **new** Immich asset — current Immich removed in-place replacement, so
the original is never overwritten.
2. Copies album, stack, favourite and sidecar associations from the source asset using the
version-appropriate copy endpoint, then adds the new asset to the same album explicitly
as a fallback. Photos without an Immich original go straight into their event's gallery.
3. Optionally moves the original to the Immich trash (`force: false`, recoverable, never
a permanent delete). This is off by default and needs `asset.delete`.
4. Records the checksum in `immich_pushes`, so sending the same render twice returns the
existing asset instead of uploading a duplicate.
The action only appears for accounts that enabled the integration, on photos with an
Immich source or an event gallery. Select several photos and use **Send to Immich** in the selection
bar, or the right-click action, to send a queue: each edit is rendered and uploaded in
turn, with a progress card, per-photo failure isolation and checksum skipping for edits
that are already there. **Open in Immich** jumps straight to the source asset.
### Metadata
With **Keep ratings, flags and keywords in sync** enabled (the default), Luminary and
Immich stay aligned:
- Luminary stars map to Immich's 1–5 rating; no stars map to unrated.
- A rejected flag maps to Immich's −1 rating; a pick maps to the favourite flag.
- Keywords map to Immich tags; removing a keyword removes that tag from the imported
asset and any edits pushed from it.
Edits made in Luminary are debounced and sent to Immich for the imported original and
every edit asset pushed from it. Album sync also reconciles in the other direction: a
rating, favourite or tag changed in Immich is written back to Luminary. Each photo keeps
a local/remote fingerprint snapshot in `immich_meta`, so only genuinely changed sides are
acted on; if both changed, the Luminary value wins. Metadata sync needs `asset.update`
and the tag permissions above, and can be turned off per account.
### Scheduled sync
Each account can enable **Keep linked albums in sync automatically** and choose 15 minutes
to once a day. The worker only touches imported albums that account already linked; it
never imports a new album on its own and never re-imports an event gallery. A sync respects the per-album interval, one job per account, and the
storage quota. Manual and automatic syncs share the same job path, so re-imports remain
idempotent. Last run time and the last error are shown in the panel.
Version differences are handled at runtime: the client reads `/api/server/version`, asks
for album assets inline first, retries with `withoutAssets=false`, and falls back to
`/api/search/metadata` on builds that paginate album contents.
---
## Raw pipeline
The browser cannot demosaic camera raw, so the server does it during upload:
@@ -879,7 +992,7 @@ including Lensfun's CC BY-SA 3.0 database, which the MIT licence does not relice
| tinyxml2 | bundled in Lensfun WASM | [leethomason/tinyxml2](https://github.com/leethomason/tinyxml2) | zlib | |
| utf8proc | bundled in Lensfun WASM | [JuliaStrings/utf8proc](https://github.com/JuliaStrings/utf8proc) | MIT | |
| `exifr` | 7.1.3 | [MikeKovarik/exifr](https://github.com/MikeKovarik/exifr) | MIT | Browser EXIF parsing |
| `nodemailer` | 7.0.13 | [nodemailer](https://github.com/nodemailer/nodemailer) | MIT-0 | SMTP notifications |
| `nodemailer` | 10.6.1 | [nodemailer](https://github.com/nodemailer/nodemailer) | MIT-0 | SMTP notifications |
| React / React DOM | 18.3.1 | [facebook/react](https://github.com/facebook/react) | MIT | |
| Vite / Vitest / plugin-react | 5.4.21 / 2.1.9 / 4.7.0 | [vitejs/vite](https://github.com/vitejs/vite) | MIT | |
| TypeScript | 5.9.3 | [microsoft/TypeScript](https://github.com/microsoft/TypeScript) | Apache-2.0 | |