import { NextResponse } from "next/server"; import { marksBackfillAction } from "../../../channels/actions"; import { ops, opsFail, optBool, reqSlug } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, dryRun?: true } // -> { ok, slug, dryRun, marks, labelled, relabelled: [{id, setAt, evidence: // {availability, observedAt, field, jobId, jobKind}}], notProven: [{id, // setAt, reason}], oldestCleanJobAt } // // Relabel a channel's do-not-clean marks written before marks said who set // them as set by the availability check (`by: "availability-check", // inferred: true`) — ONLY where the records prove it: availability.json says // the check found the video gone within a minute of the mark, and a clean // job's log, running then, names the pin. Never from the mark's note. Every // other old mark stays the operator's. A DRY RUN unless "dryRun": false. // // POST { slug, undo: true, dryRun?: true } // -> { ok, slug, dryRun, undo: true, marks, unlabelled: [{id, setAt, // evidence}], changedSince } // Every INFERRED label of the channel back to unlabelled (the operator's): // only marks with "inferred": true; setAt, note and audioRemoved stay. export async function POST(request: Request) { return ops(request, ["slug", "dryRun", "undo"], async (body) => { const r = await marksBackfillAction(reqSlug(body, "slug"), optBool(body, "dryRun") ?? true, optBool(body, "undo") ?? false); if (!r.ok) return opsFail(r.error); return NextResponse.json({ ok: true, ...r.result }); }); }