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:
+11
-12
@@ -225,6 +225,15 @@ export function createSyndicator(plugin) {
|
|||||||
try {
|
try {
|
||||||
const profile = await plugin._collections.ap_profile?.findOne({});
|
const profile = await plugin._collections.ap_profile?.findOne({});
|
||||||
const content = buildTimelineContent(properties);
|
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
||||||
|
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 = {
|
const timelineItem = {
|
||||||
uid: properties.url,
|
uid: properties.url,
|
||||||
url: properties.url,
|
url: properties.url,
|
||||||
@@ -344,19 +353,9 @@ function buildTimelineContent(properties) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular post — append permalink to match federated AS2 content.
|
// Regular post — return body content as-is.
|
||||||
// Without this, the Mastodon API timeline entry lacks the link back
|
// Permalink is appended by the caller (syndicator) for ALL post types.
|
||||||
// to the source post that fediverse users see via federation.
|
|
||||||
if (bodyText || bodyHtml) {
|
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 };
|
return { text: bodyText, html: bodyHtml };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
"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.",
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"indiekit",
|
"indiekit",
|
||||||
|
|||||||
Reference in New Issue
Block a user