diff --git a/lib/mastodon/entities/status.js b/lib/mastodon/entities/status.js index bcd5652..6ce2909 100644 --- a/lib/mastodon/entities/status.js +++ b/lib/mastodon/entities/status.js @@ -99,7 +99,17 @@ export function serializeStatus(item, { baseUrl, favouritedIds, rebloggedIds, bo } // Regular status (note, article, question) - const content = item.content?.html || item.content?.text || ""; + let content = item.content?.html || item.content?.text || ""; + + // Append permalink for own posts at read time — matches what fediverse + // users see via federation (jf2-to-as2 appends the same link). + // Done here instead of at write time so it survives backfills and cleanups. + const isOwnPost = _localPublicationUrl && item.author?.url === _localPublicationUrl; + const postUrl = item.uid || item.url; + if (isOwnPost && postUrl && !content.includes(postUrl)) { + const escaped = postUrl.replace(/&/g, "&").replace(//g, ">"); + content += `\n

\u{1F517} ${escaped}

`; + } const spoilerText = item.summary || ""; const sensitive = item.sensitive || false; const visibility = item.visibility || "public"; diff --git a/lib/syndicator.js b/lib/syndicator.js index 9946927..6739ccb 100644 --- a/lib/syndicator.js +++ b/lib/syndicator.js @@ -225,14 +225,7 @@ 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, "&").replace(//g, ">").replace(/"/g, """); - content.text = `${content.text}\n\n\u{1F517} ${properties.url}`; - content.html = `${content.html}\n

\u{1F517} ${esc(properties.url)}

`; - } + // Permalink is appended at read time by serializeStatus, not here. const timelineItem = { uid: properties.url, diff --git a/package.json b/package.json index 527174d..423515b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rmdes/indiekit-endpoint-activitypub", - "version": "3.12.1", + "version": "3.12.2", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "keywords": [ "indiekit",