import { NextResponse } from "next/server"; import { recheckServiceCookiesAction } from "../../../operations/serviceCookiesActions"; import { ops, opsFail, reqString } from "../_lib"; export const dynamic = "force-dynamic"; // POST { service: "rumble" | "youtube" | "odysee" | "archive.today" | "x" | "instagram" | } // // The cookie refresh banner's Recheck: ONE request through the service's own // path (a yt-dlp metadata request for its last clean video; a forum page // through the host's profile; archive.today's request again; for X no request // at all — the login on disk, renewed since the alert; for Instagram no // request either — the operator's word that its check is passed), as a one-step // job (kind `recheck-service-cookies`) the answer waits for: // { ok, jobId, result: "clean" | "stale" | "failed", message }. "clean" // clears the alert. A second ask while one runs for the service (a press, the // dashboard's, the timer's) is refused: 409 { ok: false, busy: true, error }. export async function POST(request: Request) { return ops(request, ["service"], async (body) => { const res = await recheckServiceCookiesAction(reqString(body, "service")); // A recheck (or another press) for the service already running: 409, busy. if (!res.ok && res.busy) return opsFail(res.error, 409, { busy: true }); if (!res.ok) return opsFail(res.error, 400, res.jobId ? { jobId: res.jobId } : {}); return NextResponse.json({ ok: true, jobId: res.jobId, result: res.result, message: res.message }); }); }