Files
immich-folio/app/api/admin/proofing/[id]/export/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

41 lines
1.6 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { withAdmin } from '@/lib/admin/withAdmin';
import { picksFor } from '@/lib/admin/proofing-view';
import { immich } from '@/lib/immich';
import { getSessionById } from '@/lib/proofSessions';
import {
exportContentType,
exportExtension,
formatExport,
type ExportFormat,
} from '@/lib/proofExport';
import { contentDisposition, safeDownloadName } from '@/lib/downloadName';
const FORMATS: ExportFormat[] = ['lightroom', 'txt', 'csv'];
/** GET ?format=lightroom|txt|csv — the selection as a file. */
export const GET = withAdmin(
async (request: NextRequest, { params }: { params: Promise<{ id: string }> }) => {
const { id } = await params;
const requested = request.nextUrl.searchParams.get('format') as ExportFormat | null;
const format = requested && FORMATS.includes(requested) ? requested : 'lightroom';
const session = await getSessionById(id);
if (!session) return NextResponse.json({ error: 'Not found' }, { status: 404 });
const album = await immich.getProofingAlbum(session.albumId).catch(() => null);
if (!album) {
return NextResponse.json({ error: 'The album is not available in Immich' }, { status: 502 });
}
const body = formatExport(picksFor(session, album), format);
const name = `${safeDownloadName(`${session.clientName} ${album.albumName}`, 'selection')}.${exportExtension(format)}`;
return new NextResponse(body, {
headers: {
'Content-Type': exportContentType(format),
'Content-Disposition': contentDisposition(name),
'Cache-Control': 'private, no-store',
},
});
},
);