import { capturePostsAction } from "../../../channels/[slug]/socialActions"; import { jobResponse, ops, optBool, optString, reqSlug, reqStringArray, } from "../_lib"; export const dynamic = "force-dynamic"; // POST { slug, ids, shots?, media?, force?, articles?, queueKey? } -> { ok: true, jobId } // // Capture specific archived posts of a social channel: a screenshot of each // (`shots`, default true) and its attached media (`media`, default true), into // the channel's posts-media//. A post that links to an X Article (its // archived text, or its card) also gets the article — read into article.json, // article.md and article.png, with its images — unless `articles` is false // (default true). Posts already captured are skipped unless `force`. The job // runs on the platform's queue, as a post fetch does. // // Every refusal is the action's own sentence: both halves off (an // articles-only run names `articles: true`), a channel that // is not a social one, a fetcher that cannot capture, an id not in the // channel's posts archive. export async function POST(request: Request) { return ops( request, ["slug", "ids", "shots", "media", "force", "articles", "queueKey"], async (body) => { const slug = reqSlug(body, "slug"); return jobResponse( await capturePostsAction( slug, reqStringArray(body, "ids"), optString(body, "queueKey"), optBool(body, "shots"), optBool(body, "media"), optBool(body, "force"), optBool(body, "articles"), ), ); }, ); }