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>
This commit is contained in:
72
app/api/proof/[token]/archive/route.ts
Normal file
72
app/api/proof/[token]/archive/route.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* GET /api/proof/:token/archive?scope=selection|album — the originals of a
|
||||
* client proofing link as a ZIP.
|
||||
*
|
||||
* What may be downloaded is the session's to say (`download: selection` or
|
||||
* `album`), every successful start counts against its `downloadLimit`, and
|
||||
* the selection ZIP is built from the saved selection, never from the request.
|
||||
* Streaming and the refusal page are shared with the album archive route.
|
||||
*/
|
||||
|
||||
import { NextRequest } from 'next/server';
|
||||
import { resolveProofAccess } from '@/lib/proofAccess';
|
||||
import { claimDownload, ProofError } from '@/lib/proofSessions';
|
||||
import { refusal, withArchiveSlot, type ArchiveStreamer } from '@/lib/zipArchive';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
/** Same budget as the album archive: a whole album of originals per request. */
|
||||
const ARCHIVE_RPM = 5;
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ token: string }> },
|
||||
) {
|
||||
const { token } = await params;
|
||||
// One slot pool with the album archive route, taken before the first Immich
|
||||
// request and before the download is counted against the link's limit.
|
||||
return withArchiveSlot(request, (stream) => streamProofArchive(request, token, stream));
|
||||
}
|
||||
|
||||
/** The handler's body, run inside the client's archive slot. */
|
||||
async function streamProofArchive(
|
||||
request: NextRequest,
|
||||
token: string,
|
||||
stream: ArchiveStreamer,
|
||||
): Promise<Response> {
|
||||
const access = await resolveProofAccess(request, token, 'proof-archive', ARCHIVE_RPM);
|
||||
if ('error' in access) {
|
||||
const status = access.error.status;
|
||||
if (status === 429) {
|
||||
const retry = Number(access.error.headers.get('Retry-After')) || undefined;
|
||||
return refusal(request, 429, 'rateLimited', retry);
|
||||
}
|
||||
if (status === 503) return refusal(request, 503, 'immichUnavailable', 30);
|
||||
if (status === 401) return access.error;
|
||||
return refusal(request, 404, 'notAvailable');
|
||||
}
|
||||
|
||||
const { session } = access;
|
||||
const scope = request.nextUrl.searchParams.get('scope') === 'album' ? 'album' : 'selection';
|
||||
if (session.download === 'none') return refusal(request, 404, 'notAvailable');
|
||||
if (scope === 'album' && session.download !== 'album') {
|
||||
return refusal(request, 404, 'notAvailable');
|
||||
}
|
||||
|
||||
const chosen = new Set(session.selection);
|
||||
const assets =
|
||||
scope === 'album' ? access.assets : access.assets.filter((asset) => chosen.has(asset.id));
|
||||
if (assets.length === 0) return refusal(request, 404, 'notAvailable');
|
||||
|
||||
try {
|
||||
await claimDownload(token, scope);
|
||||
} catch (err) {
|
||||
if (err instanceof ProofError && err.code === 'limit') {
|
||||
return refusal(request, 403, 'limitReached');
|
||||
}
|
||||
if (err instanceof ProofError) return refusal(request, 404, 'notAvailable');
|
||||
throw err;
|
||||
}
|
||||
|
||||
return stream(access.albumName, assets);
|
||||
}
|
||||
51
app/api/proof/[token]/selection/route.ts
Normal file
51
app/api/proof/[token]/selection/route.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* PUT /api/proof/:token/selection — replace a client's saved selection.
|
||||
*
|
||||
* Body: `{ "assets": [<asset token>, …] }`, the album's opaque asset tokens in
|
||||
* any order. Answers 409 once the selection has been submitted, which the page
|
||||
* turns into its locked state.
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { decodeSelection, proofError, resolveProofAccess } from '@/lib/proofAccess';
|
||||
import { MAX_SELECTION, ProofError, saveSelection } from '@/lib/proofSessions';
|
||||
import { readJsonCapped } from '@/lib/requestBody';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
/** Autosave fires once per burst of hearts; this is generous for one visitor. */
|
||||
const SELECTION_RPM = 60;
|
||||
|
||||
/** MAX_SELECTION tokens of ~70 characters each, with room to spare. */
|
||||
const MAX_BODY_BYTES = 256 * 1024;
|
||||
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ token: string }> },
|
||||
) {
|
||||
const { token } = await params;
|
||||
const access = await resolveProofAccess(request, token, 'proof-save', SELECTION_RPM);
|
||||
if ('error' in access) return access.error;
|
||||
|
||||
const body = (await readJsonCapped(request, MAX_BODY_BYTES)) as { assets?: unknown } | null;
|
||||
const assets = body?.assets;
|
||||
if (!Array.isArray(assets) || assets.length > MAX_SELECTION) {
|
||||
return proofError(400, 'Invalid selection');
|
||||
}
|
||||
const ids = decodeSelection(assets, access.assets);
|
||||
if (!ids) return proofError(400, 'Invalid selection');
|
||||
|
||||
try {
|
||||
const session = await saveSelection(token, ids);
|
||||
return NextResponse.json(
|
||||
{ ok: true, selected: session.selection.length },
|
||||
{ headers: { 'Cache-Control': 'no-store' } },
|
||||
);
|
||||
} catch (err) {
|
||||
if (err instanceof ProofError && err.code === 'submitted') {
|
||||
return proofError(409, 'Selection already submitted');
|
||||
}
|
||||
if (err instanceof ProofError) return proofError(404, 'Not found');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
44
app/api/proof/[token]/submit/route.ts
Normal file
44
app/api/proof/[token]/submit/route.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* POST /api/proof/:token/submit — lock the client's selection and notify the
|
||||
* photographer.
|
||||
*
|
||||
* Idempotent: submitting twice answers 200 both times, and only the first call
|
||||
* fires the webhook.
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { proofError, resolveProofAccess } from '@/lib/proofAccess';
|
||||
import { ProofError, submitSelection } from '@/lib/proofSessions';
|
||||
import { notifySubmitted } from '@/lib/proofWebhook';
|
||||
import { getConfig } from '@/lib/config';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
const SUBMIT_RPM = 10;
|
||||
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ token: string }> },
|
||||
) {
|
||||
const { token } = await params;
|
||||
const access = await resolveProofAccess(request, token, 'proof-submit', SUBMIT_RPM);
|
||||
if ('error' in access) return access.error;
|
||||
|
||||
try {
|
||||
const { session, firstSubmit } = await submitSelection(token);
|
||||
if (firstSubmit) {
|
||||
// Not awaited: a slow or broken webhook must not hold up the client.
|
||||
void notifySubmitted(session, access.albumName, getConfig().siteUrl);
|
||||
}
|
||||
return NextResponse.json(
|
||||
{ ok: true, submittedAt: session.submittedAt },
|
||||
{ headers: { 'Cache-Control': 'no-store' } },
|
||||
);
|
||||
} catch (err) {
|
||||
if (err instanceof ProofError && err.code === 'empty') {
|
||||
return proofError(400, 'Nothing selected');
|
||||
}
|
||||
if (err instanceof ProofError) return proofError(404, 'Not found');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user