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:
@@ -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 });
|
||||
};
|
||||
Reference in New Issue
Block a user