Commit Graph
24 Commits
Author SHA1 Message Date
Leon Tonhäuser dd60fd6ee6 feat: auto-assign new Immich albums via keyword rules
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
2026-08-25 01:05:04 +02:00
Leon Tonhäuser 86dfe8053d fix: harden production flows and user messaging 2026-08-11 16:07:13 +02:00
Leon TonhäuserandClaude 5a76c4fbb4 fix: bulk-download 500 — archiver v8 export is a class, not a callable
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>
2026-08-11 14:48:01 +02:00
Leon TonhäuserandClaude 8eadd1f408 fix: bulk-download repeat intents, error mapping, leaner membership map
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>
2026-08-11 14:40:27 +02:00
Leon TonhäuserandClaude 6a31e5f411 fix: download 404 — Immich getAlbum no longer returns assets
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>
2026-08-11 14:25:55 +02:00
Leon Tonhäuser fe2f82244d fix: resolve typescript compilation error with sharp buffer in thumbnail handler 2026-08-11 13:10:31 +02:00
Leon Tonhäuser 7e85b35486 fix: watermark svg xlink, object-contain for vertical images, remove duplicate search form 2026-08-11 13:07:30 +02:00
Leon Tonhäuser 986828893b fix: bypass broken asset.albums authorization check for thumbnails 2026-08-11 13:01:12 +02:00
Leon Tonhäuser 4667615ed0 feat: implement hard delete, email notifications, watermark, and fix bulk download 2026-08-11 12:28:39 +02:00
Leon Tonhäuser 8dd1e10fea fix: bulk download streaming reliability 2026-08-11 12:03:08 +02:00
Leon Tonhäuser d9d69ed861 fix: comprehensive portal audit - bugfixes, performance, security, logo
Critical bugs:
- Fix bulk-download: UUID idempotency key, input validation, error handling, parallel asset validation
- Fix leuchtkasten 404 link -> album page with search
- Fix revalidatePath [id] -> [albumId]
- Fix PDF crash on null invoiceNumber

Logo:
- Fix dimensions (1000x1000), dark mode support (logo-white.png), max-height constraint

UI bugs:
- Fix unsafe Date method calls (6 files)
- Fix album UUID shown instead of name in catalog
- Fix global search downloads (albumId from asset)
- Add null guard for lightbox asset map

Performance:
- Parallelize admin dashboard queries (Promise.all)
- Lazy-load recharts via next/dynamic
- Add thumbnail caching headers (24h + ETag)
- Reduce duplicate Immich API calls in usage service
- Add DB index on usages(createdAt)
- Add optimizePackageImports for lucide-react, recharts

Security:
- Input validation on bulk-download (max 100 items, UUID format, purpose length)
- Verify security headers present in next.config.ts
2026-08-11 11:50:12 +02:00
Leon Tonhäuser 0576d946c5 fix: resolve remaining typescript errors 2026-08-11 11:27:44 +02:00
Leon Tonhäuser 4a9da65901 feat: redesign dashboard, add lightbox bulk download, and standardize ui 2026-08-11 11:18:39 +02:00
Leon Tonhäuser 8728308fc6 feat: complete UI design system refactoring and fix TS build errors 2026-08-11 03:38:34 +02:00
Leon Tonhäuser 0b1ffdfdfc feat: Add flatrate billing model for editorial accounts 2026-08-11 03:27:10 +02:00
Leon Tonhäuser f7481d4cde ops: add portal deployment and backup runbook 2026-08-10 21:47:53 +02:00
Leon Tonhäuser 21871bb9ff feat: harden portal security and auditability 2026-08-10 21:46:54 +02:00
Leon TonhäuserandClaude 7f1ecd9322 feat: finalize immutable billing reports
Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-10 18:19:13 +02:00
Leon Tonhäuser 8871e4794a feat: stream originals with download accounting 2026-08-10 13:10:13 +02:00
Leon Tonhäuser 846904f3db fix: harden editorial thumbnail authorization 2026-08-09 22:32:18 +02:00
Leon Tonhäuser 66f0599653 feat: add branded editorial photo catalog 2026-08-09 22:22:31 +02:00
Leon Tonhäuser a8d4e54ffb fix: harden editorial registration flow 2026-08-09 21:04:50 +02:00
Leon Tonhäuser 9b22752ef2 feat: add editorial registration and authentication 2026-08-09 20:48:43 +02:00
Leon Tonhäuser 763098b129 chore: bootstrap portal application 2026-08-09 20:14:31 +02:00