import { checkPostAvailabilityAction } from "../../../channels/[slug]/socialActions"; import { CHECK_POST_AVAILABILITY_MODES, type CheckPostAvailabilityMode, } from "yt-dlp-transcript-common/controller/checkPostAvailability"; import { OpsInputError, jobResponse, ops, optPositiveInt, optString, reqSlug } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, mode?, limit? } -> { ok: true, jobId } // // WHICH ARCHIVED POSTS ARE GONE AT THEIR SOURCE (the channel page's "Check // deleted posts"; release 37 S5 adds this door): a check-post-availability // job. A Wayback pages channel's records are checked by their ORIGINAL URL at // its own site (lib/waybackPages/liveness-server.ts, the web pacer — never // the Wayback Machine), one request per distinct URL; any other posts // channel through its fetcher's own check. `mode`: "stale" (default) | // "unchecked" | "all"; `limit` (default 200) counts posts, or URLs for a // pages channel. The verdicts land in posts-availability.json. export async function POST(request: Request) { return ops(request, ["slug", "mode", "limit"], async (body) => { const slug = reqSlug(body, "slug"); const mode = optString(body, "mode"); if (mode !== undefined && !(CHECK_POST_AVAILABILITY_MODES as string[]).includes(mode)) { throw new OpsInputError(`"mode" must be one of ${CHECK_POST_AVAILABILITY_MODES.join(", ")}`); } const limit = optPositiveInt(body, "limit"); return jobResponse( await checkPostAvailabilityAction(slug, undefined, mode as CheckPostAvailabilityMode | undefined, limit), ); }); }