From fc165e01e116b57090fc841bad6b5ae91295d159 Mon Sep 17 00:00:00 2001 From: Sven Date: Sun, 14 Jun 2026 18:32:36 +0200 Subject: [PATCH] patch: add ap-syndicator-checkin-guard to repo + audit cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch audit (run-patches --check) surfaced 3 patch scripts that lived only in prod /usr/local/indiekit/scripts and were never committed: - patch-ap-syndicator-checkin-guard.mjs — ACTIVE (already applied, working): extends the AP syndicator skip-guard to cover both location and checkin JF2 properties. Added to repo here. - patch-ap-enrich-actor-data.mjs — OBSOLETE: its avatar/handle getIcon() effect is already present in the activitypub fork (>= 32ea375); 0/4 markers applied, getIcon present in all 3 targets. Removed from prod (backup in /tmp). - patch-ap-stubs-remove-duplicate-routes.mjs — OBSOLETE: duplicate account routes no longer exist in the fork's stubs.js. Removed from prod. After removal: run-patches --check is clean (61 already | 0 newly | 0 not found | 0 failed). Follows the established 'remove patches integrated into fork' pattern (commit 68962a3a0). --- scripts/patch-ap-syndicator-checkin-guard.mjs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scripts/patch-ap-syndicator-checkin-guard.mjs diff --git a/scripts/patch-ap-syndicator-checkin-guard.mjs b/scripts/patch-ap-syndicator-checkin-guard.mjs new file mode 100644 index 00000000..a21100a2 --- /dev/null +++ b/scripts/patch-ap-syndicator-checkin-guard.mjs @@ -0,0 +1,45 @@ +import { readFile, writeFile } from "node:fs/promises"; + +// Extend the AP syndicator checkin guard to cover both `location` and +// `checkin` properties. The upstream package only checks `location`; a +// checkin coming in without coordinates (no `location` property) would slip +// through. This patch makes both cases explicit. + +const candidates = [ + "node_modules/@rmdes/indiekit-endpoint-activitypub/lib/syndicator.js", +]; + +const oldSnippet = ` // Skip location checkins — they have a JF2 \`location\` property. + if (properties.location) { + console.info(\`[ActivityPub] Skipping syndication for location checkin: \${properties.url}\`); + return undefined; + }`; + +const newSnippet = ` // Skip location checkins — they have a JF2 \`location\` or \`checkin\` property. + if (properties.location || properties.checkin) { + console.info(\`[ActivityPub] Skipping syndication for location checkin: \${properties.url}\`); + return undefined; + }`; + +for (const filePath of candidates) { + let source; + try { + source = await readFile(filePath, "utf8"); + } catch { + console.log(`[postinstall] patch-ap-syndicator-checkin-guard: ${filePath} not found, skipping`); + continue; + } + + if (source.includes("properties.checkin")) { + console.log("[postinstall] patch-ap-syndicator-checkin-guard: already patched"); + continue; + } + + if (!source.includes(oldSnippet)) { + console.log("[postinstall] patch-ap-syndicator-checkin-guard: target snippet not found, skipping"); + continue; + } + + await writeFile(filePath, source.replace(oldSnippet, newSnippet), "utf8"); + console.log("[postinstall] patch-ap-syndicator-checkin-guard: patched syndicator.js"); +}