Files
immich-folio/app/api/admin/proofing/route.ts
Ralksta ad8b09700b release: v0.19.0
Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of
[CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md)
for the full list.

Highlights: client proofing links (#683), custom content pages (#738),
asset picker search (#740), concurrent-edit detection (#742), env-locked
settings (#739), an accessibility baseline (#741), three security fixes
with advisories (#737, #755, #759), and a pre-release quality pass
(#780–#797).

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: ralksta <ralksta@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Ralf <rohlenbo79@gmail.com>
Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com>
Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com>
Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
2026-09-29 22:50:30 +02:00

44 lines
1.7 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { withAdmin } from '@/lib/admin/withAdmin';
import { loadAlbums, toAdminSession } from '@/lib/admin/proofing-view';
import { immich } from '@/lib/immich';
import { createSession, listSessions, ProofError, sessionInputSchema } from '@/lib/proofSessions';
import { webhookUrl } from '@/lib/proofWebhook';
/** GET: every proofing link, newest first. */
export const GET = withAdmin(async () => {
const sessions = await listSessions();
const albums = await loadAlbums(sessions.map((s) => s.albumId));
const list = sessions
.map((s) => toAdminSession(s, albums.get(s.albumId) ?? null))
.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
return NextResponse.json({ sessions: list, webhookConfigured: webhookUrl() !== null });
});
/** POST: create a proofing link for one client and one album. */
export const POST = withAdmin(async (request: NextRequest) => {
const parsed = sessionInputSchema.safeParse(await request.json().catch(() => null));
if (!parsed.success) {
return NextResponse.json(
{ error: parsed.error.issues[0]?.message ?? 'Invalid input' },
{ status: 400 },
);
}
// Refuse a link to an album Immich does not have, rather than hand out a 404.
const album = await immich.getProofingAlbum(parsed.data.albumId).catch(() => null);
if (!album) {
return NextResponse.json({ error: 'Immich has no album with that ID' }, { status: 400 });
}
try {
const session = await createSession(parsed.data);
return NextResponse.json({ session: toAdminSession(session, album) }, { status: 201 });
} catch (err) {
if (err instanceof ProofError) {
return NextResponse.json({ error: err.message }, { status: 409 });
}
throw err;
}
});