From d143abf392f32383679e41078fa873f30d72445e Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Thu, 19 Mar 2026 00:16:06 +0100 Subject: [PATCH] fix: add to/cc addressing to Like and Announce activities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mastodon shared inboxes require cc:followers to route activities to local followers. Like had no to/cc at all, Announce was missing cc. Also normalize nested tags (on/art/music → music) in hashtag names. Co-Authored-By: Claude Opus 4.6 --- lib/jf2-to-as2.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/jf2-to-as2.js b/lib/jf2-to-as2.js index df62b87..693703a 100644 --- a/lib/jf2-to-as2.js +++ b/lib/jf2-to-as2.js @@ -250,9 +250,12 @@ export function jf2ToAS2Activity(properties, actorUrl, publicationUrl, options = if (postType === "like") { const likeOf = properties["like-of"]; if (!likeOf) return null; + const followersUrl = `${actorUrl.replace(/\/$/, "")}/followers`; return new Like({ actor: actorUri, object: new URL(likeOf), + to: new URL("https://www.w3.org/ns/activitystreams#Public"), + cc: new URL(followersUrl), }); } @@ -260,10 +263,12 @@ export function jf2ToAS2Activity(properties, actorUrl, publicationUrl, options = if (postType === "repost") { const repostOf = properties["repost-of"]; if (!repostOf) return null; + const followersUrl = `${actorUrl.replace(/\/$/, "")}/followers`; return new Announce({ actor: actorUri, object: new URL(repostOf), to: new URL("https://www.w3.org/ns/activitystreams#Public"), + cc: new URL(followersUrl), }); } @@ -554,7 +559,7 @@ function buildPlainTags(properties, publicationUrl, existing) { for (const cat of asArray(properties.category)) { tags.push({ type: "Hashtag", - name: `#${cat.replace(/\s+/g, "")}`, + name: `#${cat.split("/").at(-1).replace(/\s+/g, "")}`, href: `${publicationUrl}categories/${encodeURIComponent(cat)}`, }); } @@ -576,7 +581,7 @@ function buildFedifyTags(properties, publicationUrl, postType) { for (const cat of asArray(properties.category)) { tags.push( new Hashtag({ - name: `#${cat.replace(/\s+/g, "")}`, + name: `#${cat.split("/").at(-1).replace(/\s+/g, "")}`, href: new URL( `${publicationUrl}categories/${encodeURIComponent(cat)}`, ),