import { NextResponse } from "next/server"; import { reviewCompactedOriginalAction } from "../../../saved-videos/compactActions"; import { ops, opsFail, optString, reqSlug, reqVideoId } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, id, note?, formerOriginal? } // -> { ok, original, watched } // // A person's review of a compacted copy: "the compacted copy is proven good" — // after watching it (`get compaction-review` gives each video's two files and // a `smplayer` command for them). It names the copy it is for (`watched`, that // copy's sha256) and counts for that copy only. // Recorded on the original's alternate entry (`review: {at, by: "ops", note}`) // and nothing else changes — no file is touched. It is what a video not known // to be on its platform needs before drop-saved-alternate, with // "confirmOriginal": true, drops its original. Refused when the video keeps no // original beside a compacted copy, or the copy's checks did not pass. export async function POST(request: Request) { return ops(request, ["slug", "id", "note", "formerOriginal"], async (body) => { const res = await reviewCompactedOriginalAction(reqSlug(body, "slug"), reqVideoId(body, "id"), { by: "ops", // A FORMER original by its file name: the review is of the active copy that replaced it. ...(optString(body, "formerOriginal") ? { formerOriginal: optString(body, "formerOriginal") } : {}), ...(optString(body, "note") ? { note: optString(body, "note") } : {}), }); if (!res.ok) return opsFail(res.error); return NextResponse.json({ ok: true, original: res.original, watched: res.watched }); }); }