commit 2290472aeb62e7c9adfd7cb88666a23fcd38dc5b
parent 224003c8f6574c13459a77d56d38a80f0996604e
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 2 Nov 2026 19:53:01 -0500
editor: capture-posts takes "avatars" and "avatarsOnly" -- the ops route, the action, the job replay
The ops route accepts "avatars" (default on for X) and "avatarsOnly"; the
action passes both to the controller and the job spec, so a replayed job
asks the same. avatarsOnly is a run of its own for the nothing-to-capture
check and is refused before any job on a channel that is not X ("Avatars
are X's only; <fetcher> keeps none."). The research tool's capture-posts
spec takes avatarsOnly too. Route unit test and the Bluesky e2e spec cover
the keys and the refusal.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 77 insertions(+), 14 deletions(-)
diff --git a/common/lib/report/draft/research/tools.ts b/common/lib/report/draft/research/tools.ts
@@ -128,10 +128,10 @@ export const ACTION_SPECS: Record<AcquisitionAction, ActionSpec> = {
action: "capture-posts",
editorAction: "capture-posts",
description:
- "Capture archived posts of a social channel: a screenshot and the attached media of each id; thread: an X reply also shot with the post it answers above it (shot-thread.png, the replied-to author blurred unless verified).",
- properties: { slug: str, ids: strList, shots: bool, media: bool, articles: bool, thread: bool },
+ "Capture archived posts of a social channel: a screenshot and the attached media of each id; thread: an X reply also shot with the post it answers above it (shot-thread.png, the replied-to author blurred unless verified); X keeps each author's avatar (posts-media/_avatars/); avatarsOnly: only the avatars, one page per author.",
+ properties: { slug: str, ids: strList, shots: bool, media: bool, articles: bool, thread: bool, avatarsOnly: bool },
required: ["slug", "ids"],
- body: (a) => pick(a, ["slug", "ids", "shots", "media", "articles", "thread"]),
+ body: (a) => pick(a, ["slug", "ids", "shots", "media", "articles", "thread", "avatarsOnly"]),
},
"import-post": {
action: "import-post",
diff --git a/editor/app/api/ops/capture-posts/route.test.ts b/editor/app/api/ops/capture-posts/route.test.ts
@@ -167,3 +167,30 @@ test("capture-posts refuses what it cannot capture, and an id not in the archive
assert.deepEqual(await readdir(path.join(ROOT, ".jobs")).catch(() => []), []);
});
+
+test("avatars and avatarsOnly: booleans; avatarsOnly is a run of its own, X's only — refused before any job", async () => {
+ for (const key of ["avatars", "avatarsOnly"]) {
+ const bad = await post({ slug: SLUG, ids: ["111"], [key]: "yes" });
+ assert.equal(bad.status, 400, key);
+ assert.match(bad.error, new RegExp(`"${key}" must be a boolean`));
+ }
+ // Both halves off is no refusal for an avatars-only run: past it, to the
+ // next one (an id not archived).
+ const stray = await post({ slug: SLUG, ids: ["999"], shots: false, media: false, avatarsOnly: true });
+ assert.equal(stray.status, 400);
+ assert.equal(stray.error, "1 id(s) not in demo-x's posts archive: 999");
+ // Another platform keeps none.
+ await channel("example-bsky-avatars", {
+ handling: "transcribe",
+ sourceKind: "social",
+ platform: "bluesky",
+ postFetcher: "bluesky-atproto",
+ socialHandle: "example.bsky.social",
+ name: "Example (Bluesky)",
+ url: "https://bsky.app/profile/example.bsky.social",
+ });
+ const bsky = await post({ slug: "example-bsky-avatars", ids: ["1"], avatarsOnly: true });
+ assert.equal(bsky.status, 400);
+ assert.match(bsky.error, /^Avatars are X's only; .* keeps none\.$/);
+ assert.deepEqual(await readdir(path.join(ROOT, ".jobs")).catch(() => []), []);
+});
diff --git a/editor/app/api/ops/capture-posts/route.ts b/editor/app/api/ops/capture-posts/route.ts
@@ -10,7 +10,7 @@ import {
export const dynamic = "force-dynamic";
-// POST { slug, ids, shots?, media?, force?, articles?, thread?, threadRedact?, queueKey? } -> { ok: true, jobId }
+// POST { slug, ids, shots?, media?, force?, articles?, thread?, threadRedact?, avatars?, avatarsOnly?, 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
@@ -25,14 +25,23 @@ export const dynamic = "force-dynamic";
// skipped unless `force`. The job runs on the platform's queue, as a post
// fetch does.
//
+// X keeps each post author's AVATAR, read off the page the shot loads (with
+// `thread`, the replied-to and quoted authors' too), in
+// `posts-media/_avatars/<handle>.<ext>` + `avatars.json` -- `avatars: false`
+// turns that off. `avatarsOnly: true` loads ONE post page per distinct
+// archived author for the avatars alone: no shot, media, article or thread
+// shot, no capture record, no availability; an author already stored is
+// skipped unless `force`. One author's avatar is one page load:
+// {"slug":"ObviousRises-x","ids":["<one of his post ids>"],"avatarsOnly":true}
+//
// 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.
+// channel's posts archive, `avatarsOnly` on a channel that is not X.
export async function POST(request: Request) {
return ops(
request,
- ["slug", "ids", "shots", "media", "force", "articles", "thread", "threadRedact", "queueKey"],
+ ["slug", "ids", "shots", "media", "force", "articles", "thread", "threadRedact", "avatars", "avatarsOnly", "queueKey"],
async (body) => {
const slug = reqSlug(body, "slug");
return jobResponse(
@@ -44,7 +53,12 @@ export async function POST(request: Request) {
optBool(body, "media"),
optBool(body, "force"),
optBool(body, "articles"),
- { thread: optBool(body, "thread"), threadRedact: body.threadRedact as boolean | Record<string, boolean> | undefined },
+ {
+ thread: optBool(body, "thread"),
+ threadRedact: body.threadRedact as boolean | Record<string, boolean> | undefined,
+ avatars: optBool(body, "avatars"),
+ avatarsOnly: optBool(body, "avatarsOnly"),
+ },
),
);
},
diff --git a/editor/app/channels/[slug]/socialActions.ts b/editor/app/channels/[slug]/socialActions.ts
@@ -43,6 +43,7 @@ import {
type CheckPostAvailabilityMode,
} from "yt-dlp-transcript-common/controller/checkPostAvailability";
import {
+ avatarsOnlyProblem,
capturePosts,
capturePostsProblem,
NOTHING_TO_CAPTURE,
@@ -302,7 +303,10 @@ export async function fetchPostsAction(
// links to an X Article gets the article too unless `articles` is false. An X
// reply gets its thread shot (the post it answers over it) with `thread`
// (default: the channel's `postCaptureThread`), its parent's author blurred
-// by the rule unless `threadRedact` says otherwise.
+// by the rule unless `threadRedact` says otherwise. X keeps the authors'
+// avatars from the pages it loads (`avatars: false` turns that off);
+// `avatarsOnly` loads one page per archived author for them alone (X only,
+// refused here elsewhere).
export async function capturePostsAction(
slug: string,
ids: string[],
@@ -311,13 +315,13 @@ export async function capturePostsAction(
media?: boolean,
force?: boolean,
articles?: boolean,
- more: { thread?: boolean; threadRedact?: ThreadRedactKnob } = {},
+ more: { thread?: boolean; threadRedact?: ThreadRedactKnob; avatars?: boolean; avatarsOnly?: boolean } = {},
): Promise<StreamActionResult> {
- const { thread } = more;
+ const { thread, avatars, avatarsOnly } = more;
const redact = parseThreadRedact(more.threadRedact);
if (!redact.ok) return { ok: false, error: redact.error };
const threadRedact = redact.value;
- if (nothingToCapture({ shots, media, articles, thread })) return { ok: false, error: NOTHING_TO_CAPTURE };
+ if (nothingToCapture({ shots, media, articles, thread, avatarsOnly })) return { ok: false, error: NOTHING_TO_CAPTURE };
const wanted = [...new Set(ids)];
if (wanted.length === 0) return { ok: false, error: "No post ids to capture." };
const paths = getPaths();
@@ -329,12 +333,14 @@ export async function capturePostsAction(
// A Wayback pages channel has no fetcher: its records are rendered from
// their captures, on archive.org's queue (release 37 S4).
const pages = isWaybackPagesChannel(config);
+ if (pages && avatarsOnly) return { ok: false, error: avatarsOnlyProblem(undefined, "a Wayback pages channel")! };
if (!pages) {
await registerBuiltinSocialFetchers();
- const problem = capturePostsProblem(
- resolveSocialFetcher(config.postFetcher, config.url),
- );
+ const fetcher = resolveSocialFetcher(config.postFetcher, config.url);
+ const problem = capturePostsProblem(fetcher);
if (problem) return { ok: false, error: problem };
+ const nope = avatarsOnly ? avatarsOnlyProblem(fetcher?.platform, fetcher?.label ?? "") : null;
+ if (nope) return { ok: false, error: nope };
}
const stray = strayCaptureIds(
wanted,
@@ -355,6 +361,8 @@ export async function capturePostsAction(
queueKey, ids: wanted, shots, media, force, articles,
...(thread !== undefined ? { thread } : {}),
...(threadRedact !== undefined ? { threadRedact } : {}),
+ ...(avatars !== undefined ? { avatars } : {}),
+ ...(avatarsOnly ? { avatarsOnly } : {}),
},
},
fn: async (onLog, signal, _progress, ctx) => {
@@ -369,6 +377,8 @@ export async function capturePostsAction(
articles,
thread,
threadRedact,
+ avatars,
+ avatarsOnly,
onLog,
signal,
drain: ctx.drainSignal,
diff --git a/editor/app/jobs/jobReplayRegistry.ts b/editor/app/jobs/jobReplayRegistry.ts
@@ -443,6 +443,8 @@ export const JOB_REPLAY_HANDLERS: Record<string, ReplayHandler> = {
thread: bool(p.thread),
// A boolean or { id: boolean }; the action refuses any other shape.
threadRedact: p.threadRedact as boolean | Record<string, boolean> | undefined,
+ avatars: bool(p.avatars),
+ avatarsOnly: bool(p.avatarsOnly),
},
);
},
diff --git a/editor/e2e/capture-posts.spec.ts b/editor/e2e/capture-posts.spec.ts
@@ -123,6 +123,16 @@ test("capture-posts on a Bluesky channel: shots cropped to the post, its images,
`/profile/${HANDLE}/post/${withImages}`,
`/profile/${HANDLE}/post/${textOnly}`,
]);
+
+ // Avatars are X's: a Bluesky capture keeps none, and an avatars-only
+ // run here is refused by name before any job.
+ expect(await readdir(media)).not.toContain("_avatars");
+ const av = await request.post(`${baseUrl}/api/ops/capture-posts`, {
+ headers: AUTH,
+ data: { slug: SLUG, ids, avatarsOnly: true },
+ });
+ expect(av.status()).toBe(400);
+ expect(((await av.json()) as { error?: string }).error).toMatch(/^Avatars are X's only; .* keeps none\.$/);
} finally {
await rm(originFile, { force: true });
await bsky.close();