fix: album assignment + approval error handling

Album assignment 500'd with IMMICH_UNAVAILABLE because grantAlbum verified the
album via getAlbum, which pulled the full album incl. all assets — large albums
blew the 15s timeout. Request ?withoutAssets=true so Immich returns metadata
only (no consumer reads .assets); make assets optional in the schema.

Album thumbnails 500'd because next/image rejected the ?albumId= query string
(images.localPatterns). Switch the album page to a plain <img>, matching the
editorial catalog (next/image was used in exactly one place).

Overhaul action error handling: grantAlbumAction/revokeAlbumAction/approveEditorialAction
returned a thrown Error, which Next.js turns into an opaque error-digest page —
the German message never reached the admin. They now return {ok,message}; new
client AlbumGrantForm + ApproveForm use useActionState to show the message
inline. Auth (requireAdmin) still throws (guarded by the layout). Update both
action test files to the result contract.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude committed 2026-08-11 02:09:16 +02:00
1 parent 7aeceee078
commit 089f5f7035
9 files changed
+233 -60

No files matched your search

+5 -16
View File
@@ -1,5 +1,6 @@
import Link from "next/link";
import { ApproveForm } from "@/components/admin/approve-form";
import { approveEditorialAction } from "@/app/admin/redaktionen/[id]/actions";
export type EditorialDetail = {
@@ -51,22 +52,10 @@ export function EditorialDetailContent({
<p>Die Redaktion ist freigegeben (Netto {formatCents(editorial.currentPriceCents ?? 0)}).</p>
) : (
<>
<form action={approveEditorialAction.bind(null, editorial.id)} className="account-form">
<label>
Individueller Nettopreis (EUR)
<input
inputMode="decimal"
min="0.01"
name="priceEuros"
required
step="0.01"
type="number"
/>
</label>
<button type="submit" disabled={!canApprove}>
Redaktion freigeben
</button>
</form>
<ApproveForm
action={approveEditorialAction.bind(null, editorial.id)}
canApprove={canApprove}
/>
<p>{approvalHint}</p>
<Link href={`/admin/redaktionen/${editorial.id}/alben`}>Albumrechte verwalten</Link>
</>
+5 -2
View File
@@ -43,7 +43,10 @@ const albumSummarySchema = z
.passthrough();
const albumSchema = albumSummarySchema.extend({
assets: z.array(assetSchema),
// `getAlbum` requests `?withoutAssets=true` so Immich returns album metadata
// without the full asset list — otherwise large albums blow past the request
// timeout and surface as IMMICH_UNAVAILABLE. No consumer reads `.assets`.
assets: z.array(assetSchema).optional().default([]),
});
const metadataSearchSchema = z
@@ -324,7 +327,7 @@ export function createImmichClient({
},
getAlbum(albumId, signal) {
return requestJson<ImmichAlbum>(
`/albums/${encodeURIComponent(albumId)}`,
`/albums/${encodeURIComponent(albumId)}?withoutAssets=true`,
{ method: "GET" },
albumSchema,
signal,