The UI goes live on the main domain directly, so the second-instance
compose file and the AUTO_RULE_SYNC_DISABLED switch are not needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the hand-rolled Tailwind/shadcn look with Sakani UI across the
editorial area, the admin area and all signed-out pages.
- AppShell (Sakani Sidebar + TopBar) for /redaktion and /admin, with a
mobile drawer, theme toggle, sign-out, legal links and a "Was ist neu"
button; PublicShell for login, registration, password, 2FA and errors.
- Shared primitives (Button, Card, Input, PageHeader) now render Sakani;
components/ui/sakani.tsx is the client boundary for Server Components
(Sakani ships no "use client") and adds FormSelect (native form value)
and DataTable (element cells from the server).
- Legacy CSS variables map onto Sakani tokens; globals.css shrinks from
~2200 to ~700 lines. Geist replaces Inter. recharts/lucide-react dropped
(charts via Sakani BarChart).
- Release notes popup per area, shown once per version (localStorage) and
reopenable from the sidebar; native <dialog> for focus trapping.
- Fixes found while testing: TOTP field reused the typed password in
clear text, modal dialogs sat top-left, invisible unchecked checkboxes
in dark mode.
- Parallel run: compose.parallel.yaml, AUTO_RULE_SYNC_DISABLED switch and
docs/operations.md §8 (start, rollback, cutover).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grouped SUM over usages with billingStatus open/reopened (same selectable
set as the billing page; voided excluded) per editorial, rendered as an
amber-highlighted 'Offen' suffix in each card footer.
New /admin/alben page: all Immich albums with per-album editorial grant
chips (link + one-click revoke) and a bulk-grant form (multiple albums x
multiple editorials, select-all, search). bulkGrantAlbums validates album
existence once via listAlbums, skips already-active pairs, and commits
each pair in its own transaction with full audit attribution.
Squash the 13 historical migrations into one generated baseline whose
journal entry reuses the original 0000 timestamp: the migrator skips it
on every existing database (prod journal stuck at 0006) and applies it
only on fresh ones. Parity with the old chain verified via pg_dump diff
plus fresh/existing/prod-simulated drizzle-kit migrate runs. Historical
files move to drizzle-history/pre-squash-2026-08/ for integration tests
that exercise legacy migration behavior.
Also repair db tests that already failed before this change:
- raw SQL targeted users, but the table has always been "user"
- membership recheck mocked legacy getAsset.albums instead of searchPhotos
- audit rollback assertion walks drizzle's wrapped error cause chain
- keyset index probe pinned to NULLS LAST ordering, removing a planner
cost tie-break that flipped with index creation order
Adds failedVerificationCount and lockedUntil (brute-force tracking
maintained by the two-factor plugin). The adapter rejects any
two-factor endpoint while declared fields are missing from the drizzle
schema; verified was already added in the previous commit.
The two-factor plugin reads/writes a verified boolean on the twoFactor
model (set true by verify-totp); without it the drizzle adapter rejects
every /two-factor/enable call.
Implements OWASP audit recommendations P1-P3:
P1 - Two-factor authentication (TOTP) mandatory for admins:
- better-auth twoFactor plugin; new two_factor table + user flag
(migration 0010, MUST run before deploying the app)
- requireAdmin throws TWO_FACTOR_REQUIRED without a finished setup;
pages redirect to the new /zwei-faktor wizard which uses a weak
guard (allowWithoutTwoFactor) so admins can never lock themselves
out. Wizard lives outside /admin to avoid layout redirect loops.
- login flow handles twoFactorRedirect and asks for the TOTP code;
backup codes are shown once during enablement
P2 - Step-up for destructive operations (ASVS 2.5.4):
- hardDeleteEditorialAction and resetUsageDataAction reject sessions
older than 15 minutes (SESSION_STALE) with actionable German
messages instead of throwing opaque digests
P3 - Password policy (NIST 800-63B):
- minimum length raised from 8 to 12 plus common-password denylist,
enforced for registration AND reset/change via a before-hook
Adds an "Archivierung aufheben" action on the editorial detail page:
clears the archive markers, reactivates suspended accounts and
re-activates exactly the album grants that were revoked by the archive
step (matched via the archive timestamp, skipping albums that received
a fresh active grant in the meantime).
Admins can now wipe an editorial's usage footprint (usages, download
events, billing reports incl. items and related audit rows) so test
accounts no longer pollute dashboard statistics. Grants, price, status
and login stay untouched; the action is confirmed by typing the
editorial name.
Hard delete previously failed with FK violations as soon as a usage had
ever been billed or an address saved:
- billing_report_items (restrict -> usages) were never deleted
- billing_address_versions were deleted before the referencing
current_billing_address_version_id and their self-referencing
superseded_by_id, both restrict
Both are now handled in correct FK order inside the transaction; the
audit trail of the deleted editorial is purged and verification tokens
are removed.
Docker Compose passes undeclared variables as empty strings
(CRON_SECRET="" etc.), which crashed env validation while loading the
instrumentation hook. A throwing register() made Next.js answer every
route with 500 while the process stayed alive.
- parse optional CRON_SECRET / AUTO_RULE_SYNC_INTERVAL_SECONDS via
plain preprocess helpers that map blank strings to unset (zod v4
does not accept preprocess-produced undefined through .optional())
- guard instrumentation register() so scheduler failures can never
break request handling
Auto-assignment rules were only applied when an admin clicked
"Regeln jetzt anwenden". New albums created in Immich therefore
never reached editorials automatically.
- applyAllRules() syncs every active editorial's keywords against the
full album list in one pass and grants matches as system actor
- in-process scheduler (src/instrumentation.ts) runs the sync every
AUTO_RULE_SYNC_INTERVAL_SECONDS (default 120s)
- POST /api/cron/album-sync allows external triggers via CRON_SECRET
- overlapping sync runs coalesce to avoid duplicate grants/emails
archiver v8 changed its CJS export from a function to an object of class
constructors ({ Archiver, ZipArchive, TarArchive, JsonArchive }). The route
still called archiver('zip', opts), which throws `TypeError: archiver is not
a function` — a deterministic throw in the main flow, returning 500.
This was masked until the prior membership fix: before it, the empty
assetToGrantedAlbum map made the route 404 at "No valid assets found"
*before* reaching the archiver line. Once the map populated and downloads
were authorized, execution reached archiver('zip') and threw.
Fixed: `new archiver.ZipArchive({ zlib: { level: 0 } })` — same
pipe/append/finalize/abort interface. Verified the full round-trip
(append → finalize → Readable.toWeb → drain) produces a valid PK zip.
Also surface the server error code in DownloadLightboxForm so future
failures show the real code (status + {code}) in the browser console and
alert instead of a generic "Download fehlgeschlagen".
Co-Authored-By: Claude <noreply@anthropic.com>
The bulk-download handler still returned 500 after the membership fix.
Three issues:
1. Repeat downloads were broken: the handler passed priorUsages[0].id
(the usage id) straight as downloadId, but claimAuthorized looks up
download_events.id (the intent id) — so repeat assets never matched
and were silently skipped. Now calls createRepeatDownload to mint a
proper repeat intent, matching the single-download flow.
2. The catch block returned a generic 500 for every error, hiding the
cause (the user only saw "Download fehlgeschlagen"). Added
mappedBulkError so UsageAccountingError surfaces as its real code
(503 IMMICH_UNAVAILABLE, 404 ASSET_NOT_IN_ALBUM, …) and the server
log keeps the full stack.
3. The assetId→album map was built by fetching up to 1000 assets per
granted album WITH withExif, then createNewUsage re-fetched per
asset — heavy enough to time Immich out under load. The map only
needs ids, so it now passes withExif:false (searchPhotos gained a
withExif option, default true to preserve the gallery's orientation
filter and masonry aspect ratios).
Co-Authored-By: Claude <noreply@anthropic.com>
getAlbum no longer returns assets on current Immich (AlbumService.get uses
{ withAssets: false }), so the old "getAlbum + iterate album.assets" best
practice is wrong and caused the download-404 bug. Document the
search/metadata id+albumIds membership check now in use.
Co-Authored-By: Claude <noreply@anthropic.com>
The previous getAlbum fix (removing ?withoutAssets=true) was insufficient:
current Immich's GET /albums/:id NEVER returns assets — AlbumService.get
calls findOrFail with { withAssets: false } and the withoutAssets param is
gone. So album.assets was always empty and every download still failed with
ASSET_NOT_IN_ALBUM → 404. The AI_MEMORY "getAlbum + iterate album.assets"
guidance was stale (written for an older Immich API).
Membership is now verified via /search/metadata with an id + albumIds filter,
which returns the asset only if it belongs to the album. This is the
authoritative test (asset.albums is unreliable for older assets too).
- usages/service.ts: loadRequestedAlbum checks isAssetInAlbum via searchPhotos
before fetching the album name; getAlbum now only provides albumName.
- bulk-download/route.ts: build the assetId→album map via searchPhotos per
granted album instead of the empty getAlbum().assets iteration.
- immich client/types: add optional `id` to the searchPhotos input.
- tests: usages mocks now stub searchPhotos; the 13 pre-existing service
test failures (mock returned getAlbum without assets → TypeError) are
resolved — 20/20 pass.
Co-Authored-By: Claude <noreply@anthropic.com>
Three production bugs on redaktionen.leon-tonhaeuser.de:
1. Download 404 (POST /api/download-intents → 404). getAlbum requested
?withoutAssets=true, so album.assets was always empty and the usages
membership check (album.assets.some(id)) always failed → ASSET_NOT_IN_ALBUM
→ 404. Same root cause broke bulk-download's assetToGrantedAlbum map.
Removed withoutAssets so consumers that authorize via album.assets get the
real list; grants/thumbnail consumers ignore the extra data.
2. _next/image 400 on thumbnail proxy. next/image's optimizer choked on the
watermarked streaming thumbnail response. Thumbnails are already
server-resized to 800px, so the optimizer added nothing — switched
leuchtkasten + admin AlbumGrid to plain <img>, matching photo-gallery.
3. Cross-album search "finds nothing". Immich albumIds is AND across albums
(PR #18985): one /search/metadata call with all granted ids requires the
asset to be in EVERY album, so single-album photos never match. Album-
internal search passed one id so it worked. Fan out per granted album and
merge; callers already paginate in-app.
Also drop the jahr filter from the album-internal search form (unnecessary
within a single album); backend still honors a jahr query param.
Co-Authored-By: Claude <noreply@anthropic.com>
The root layout already renders <LegalFooter/> (Impressum, Datenschutz,
Nutzungsbedingungen) on every page. The login page defined its own local
LegalFooter with the same three links, and the registration form carried a
standalone Impressum link — so Impressum (and on login, all three) appeared
twice. Drop the redundant per-page copies; the global footer covers them.
Co-Authored-By: Claude <noreply@anthropic.com>
Album overview:
- AlbumContactSheet now uses cover tiles in the photo-gallery aesthetic:
object-fit: cover, 4/3 tiles, persistent bottom gradient with album name
+ photo count, hover zoom. Drops the old 3:2 contain tiles + monospace
caption strip.
Diagnostics (download + merkzettel both failed silently for the user):
- UsageDialog now reads the server's { code } from /api/download-intents and
maps each stable error code (FORBIDDEN, NOT_FOUND, UPSTREAM_UNAVAILABLE,
ACCOUNTING_UNAVAILABLE, ...) to a specific German message instead of the
generic "try again". The fallback includes the raw code so unmapped
failures stay actionable when reported back.
- LightboxToggleButton logs the caught server-action error to the console
(and notes the dev terminal) instead of reverting the optimistic toggle
with no signal. Root cause still needs the live error; this makes it
visible.
Co-Authored-By: Claude <noreply@anthropic.com>