From 445aab5632b4a395a222d6108352dcd8bfb6cadd Mon Sep 17 00:00:00 2001 From: svemagie <869694+svemagie@users.noreply.github.com> Date: Fri, 13 Mar 2026 07:49:19 +0100 Subject: [PATCH] fix: serve like/repost posts as Note for AP content negotiation Returning a bare Like/Announce activity breaks Mastodon's authorize_interaction flow because it expects a content object (Note/Article). Serve as Note with emoji + linked URL instead. Co-Authored-By: Claude Sonnet 4.6 --- lib/jf2-to-as2.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/jf2-to-as2.js b/lib/jf2-to-as2.js index 6bfb119..f355e5e 100644 --- a/lib/jf2-to-as2.js +++ b/lib/jf2-to-as2.js @@ -52,20 +52,38 @@ export function jf2ToActivityStreams(properties, actorUrl, publicationUrl) { const postType = properties["post-type"]; if (postType === "like") { + // Serve like posts as Note objects for AP content negotiation. + // Returning a bare Like activity breaks Mastodon's authorize_interaction + // flow because it expects a content object (Note/Article), not an activity. + const likeOf = properties["like-of"]; + const postUrl = resolvePostUrl(properties.url, publicationUrl); return { "@context": "https://www.w3.org/ns/activitystreams", - type: "Like", - actor: actorUrl, - object: properties["like-of"], + type: "Note", + id: postUrl, + attributedTo: actorUrl, + published: properties.published, + url: postUrl, + to: ["https://www.w3.org/ns/activitystreams#Public"], + cc: [`${actorUrl.replace(/\/$/, "")}/followers`], + content: `\u2764\uFE0F ${likeOf}`, }; } if (postType === "repost") { + // Same rationale as like — serve as Note for content negotiation. + const repostOf = properties["repost-of"]; + const postUrl = resolvePostUrl(properties.url, publicationUrl); return { "@context": "https://www.w3.org/ns/activitystreams", - type: "Announce", - actor: actorUrl, - object: properties["repost-of"], + type: "Note", + id: postUrl, + attributedTo: actorUrl, + published: properties.published, + url: postUrl, + to: ["https://www.w3.org/ns/activitystreams#Public"], + cc: [`${actorUrl.replace(/\/$/, "")}/followers`], + content: `\u{1F501} ${repostOf}`, }; }