From ad1ecce943906b2161da1222d7840f4829640233 Mon Sep 17 00:00:00 2001 From: Sven Date: Wed, 15 Apr 2026 21:50:57 +0200 Subject: [PATCH] fix: run ap-search-remote-uid-guard after ap-search-url-resolve-remote The uid-guard patch anchors to markers written by the remote-search patch, so it must run after it. Moved the uid-guard runner block below the ap-search-url-resolve-remote block to fix ordering dependency. Co-Authored-By: Claude Sonnet 4.6 --- scripts/patch-ap-mastodon-misc.mjs | 37 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/patch-ap-mastodon-misc.mjs b/scripts/patch-ap-mastodon-misc.mjs index d33eda1d..f4b1fd7b 100644 --- a/scripts/patch-ap-mastodon-misc.mjs +++ b/scripts/patch-ap-mastodon-misc.mjs @@ -275,24 +275,6 @@ const UID_GUARD_NEW = ` if (!_rData?.uid) throw new Error("remote AP object has no uid"); ${UID_GUARD_MARKER}\n` + ` const _rStored = await addTimelineItem(collections, _rData); ${SEARCH_REMOTE_MARKER}`; -let uidGuardDone = false; -for (const f of SEARCH_CANDIDATES) { - if (!(await fileExists(f))) continue; - const src = await readFile(f, "utf8"); - if (src.includes(UID_GUARD_MARKER)) { - console.log(`[postinstall] ${SCRIPT}: ap-search-remote-uid-guard already applied in ${f}`); - uidGuardDone = true; break; - } - if (!src.includes(UID_GUARD_OLD)) { - console.warn(`[postinstall] ${SCRIPT}: ap-search-remote-uid-guard — anchor not found in ${f}`); - continue; - } - await writeFile(f, src.replace(UID_GUARD_OLD, UID_GUARD_NEW), "utf8"); - console.log(`[postinstall] ${SCRIPT}: applied ap-search-remote-uid-guard to ${f}`); - total++; uidGuardDone = true; break; -} -if (!uidGuardDone) console.log(`[postinstall] ${SCRIPT}: ap-search-remote-uid-guard — no target file found`); - let searchRemoteDone = false; for (const f of SEARCH_CANDIDATES) { if (!(await fileExists(f))) continue; @@ -311,6 +293,25 @@ for (const f of SEARCH_CANDIDATES) { } if (!searchRemoteDone) console.log(`[postinstall] ${SCRIPT}: ap-search-url-resolve-remote — no target file found or no changes`); +// uid-guard must run AFTER ap-search-url-resolve-remote (depends on its markers) +let uidGuardDone = false; +for (const f of SEARCH_CANDIDATES) { + if (!(await fileExists(f))) continue; + const src = await readFile(f, "utf8"); + if (src.includes(UID_GUARD_MARKER)) { + console.log(`[postinstall] ${SCRIPT}: ap-search-remote-uid-guard already applied in ${f}`); + uidGuardDone = true; break; + } + if (!src.includes(UID_GUARD_OLD)) { + console.warn(`[postinstall] ${SCRIPT}: ap-search-remote-uid-guard — anchor not found in ${f}`); + continue; + } + await writeFile(f, src.replace(UID_GUARD_OLD, UID_GUARD_NEW), "utf8"); + console.log(`[postinstall] ${SCRIPT}: applied ap-search-remote-uid-guard to ${f}`); + total++; uidGuardDone = true; break; +} +if (!uidGuardDone) console.log(`[postinstall] ${SCRIPT}: ap-search-remote-uid-guard — no target file found`); + // ── patch-ap-resolve-actor-timeout: cap actor lookup at 8 s + log failures ─── // When Mastodon client clicks a @mention handle, /api/v1/accounts/lookup calls // resolveRemoteAccount → lookupWithSecurity → ctx.lookupObject (no timeout).