Files
indiekit-server/scripts/patch-ap-syndicator-checkin-guard.mjs
Sven fc165e01e1
Deploy Indiekit Server / deploy (push) Successful in 35s
patch: add ap-syndicator-checkin-guard to repo + audit cleanup
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).
2026-06-14 18:32:36 +02:00

46 lines
1.7 KiB
JavaScript

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");
}