feat: picdrop delivery — worker delivers on job completion, /api/deliver for manual, gallery default 'POSTER LEA', library bulk send + status badges

This commit is contained in:
2026-07-23 15:41:04 +00:00
parent 25d0a5cd97
commit 26c3e0ef07
4 changed files with 81 additions and 3 deletions
+18
View File
@@ -0,0 +1,18 @@
import type { APIRoute } from 'astro';
import { deliverItem } from '../../lib/delivery';
export const prerender = false;
const json = (b: unknown, s = 200) =>
new Response(JSON.stringify(b), { status: s, headers: { 'Content-Type': 'application/json' } });
// Body: { itemIds: [...] } — Auswahl (nachträglich) nach Picdrop schicken.
export const POST: APIRoute = async ({ request, locals }) => {
if (!locals.user) return new Response('Unauthorized', { status: 401 });
const b = await request.json();
const ids: string[] = b.itemIds || [];
if (!ids.length) return json({ error: 'Keine Auswahl.' }, 400);
const results = [];
for (const id of ids) results.push({ id, ...(await deliverItem(id)) });
const ok = results.filter((r) => r.ok).length;
return json({ delivered: ok, total: ids.length, results });
};