mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 <a href="${likeOf}">${likeOf}</a>`,
|
||||
};
|
||||
}
|
||||
|
||||
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} <a href="${repostOf}">${repostOf}</a>`,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user