mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
fix: add to/cc addressing to Like and Announce activities
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)}`,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user