fix: append permalink to all post types in ap_timeline

The permalink was only appended for regular posts (notes/articles)
inside buildTimelineContent. Interaction types (likes, bookmarks,
reposts) returned early before the permalink code ran. Moved permalink
appending to the syndicator caller so it applies universally.
This commit is contained in:
Ricardo
2026-03-31 11:32:34 +02:00
parent 6e63422c21
commit c3e6c5e66a
2 changed files with 12 additions and 13 deletions
+11 -12
View File
@@ -225,6 +225,15 @@ export function createSyndicator(plugin) {
try {
const profile = await plugin._collections.ap_profile?.findOne({});
const content = buildTimelineContent(properties);
// Append permalink to ALL post types so the Mastodon API timeline
// matches what fediverse users see via federation (jf2-to-as2 appends it too).
if (properties.url) {
const esc = (s) => String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
content.text = `${content.text}\n\n\u{1F517} ${properties.url}`;
content.html = `${content.html}\n<p>\u{1F517} <a href="${esc(properties.url)}">${esc(properties.url)}</a></p>`;
}
const timelineItem = {
uid: properties.url,
url: properties.url,
@@ -344,19 +353,9 @@ function buildTimelineContent(properties) {
};
}
// Regular post — append permalink to match federated AS2 content.
// Without this, the Mastodon API timeline entry lacks the link back
// to the source post that fediverse users see via federation.
// Regular post — return body content as-is.
// Permalink is appended by the caller (syndicator) for ALL post types.
if (bodyText || bodyHtml) {
const postUrl = properties.url;
if (postUrl) {
const linkText = `\n\n\u{1F517} ${postUrl}`;
const linkHtml = `<p>\u{1F517} <a href="${esc(postUrl)}">${esc(postUrl)}</a></p>`;
return {
text: `${bodyText}${linkText}`,
html: `${bodyHtml}\n${linkHtml}`,
};
}
return { text: bodyText, html: bodyHtml };
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@rmdes/indiekit-endpoint-activitypub",
"version": "3.12.0",
"version": "3.12.1",
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
"keywords": [
"indiekit",