@rmdes/indiekit-endpoint-activitypub 3.12.0 → 3.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,7 +99,17 @@ export function serializeStatus(item, { baseUrl, favouritedIds, rebloggedIds, bo
99
99
  }
100
100
 
101
101
  // Regular status (note, article, question)
102
- const content = item.content?.html || item.content?.text || "";
102
+ let content = item.content?.html || item.content?.text || "";
103
+
104
+ // Append permalink for own posts at read time — matches what fediverse
105
+ // users see via federation (jf2-to-as2 appends the same link).
106
+ // Done here instead of at write time so it survives backfills and cleanups.
107
+ const isOwnPost = _localPublicationUrl && item.author?.url === _localPublicationUrl;
108
+ const postUrl = item.uid || item.url;
109
+ if (isOwnPost && postUrl && !content.includes(postUrl)) {
110
+ const escaped = postUrl.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
111
+ content += `\n<p>\u{1F517} <a href="${escaped}">${escaped}</a></p>`;
112
+ }
103
113
  const spoilerText = item.summary || "";
104
114
  const sensitive = item.sensitive || false;
105
115
  const visibility = item.visibility || "public";
package/lib/syndicator.js CHANGED
@@ -225,6 +225,8 @@ export function createSyndicator(plugin) {
225
225
  try {
226
226
  const profile = await plugin._collections.ap_profile?.findOne({});
227
227
  const content = buildTimelineContent(properties);
228
+ // Permalink is appended at read time by serializeStatus, not here.
229
+
228
230
  const timelineItem = {
229
231
  uid: properties.url,
230
232
  url: properties.url,
@@ -344,19 +346,9 @@ function buildTimelineContent(properties) {
344
346
  };
345
347
  }
346
348
 
347
- // Regular post — append permalink to match federated AS2 content.
348
- // Without this, the Mastodon API timeline entry lacks the link back
349
- // to the source post that fediverse users see via federation.
349
+ // Regular post — return body content as-is.
350
+ // Permalink is appended by the caller (syndicator) for ALL post types.
350
351
  if (bodyText || bodyHtml) {
351
- const postUrl = properties.url;
352
- if (postUrl) {
353
- const linkText = `\n\n\u{1F517} ${postUrl}`;
354
- const linkHtml = `<p>\u{1F517} <a href="${esc(postUrl)}">${esc(postUrl)}</a></p>`;
355
- return {
356
- text: `${bodyText}${linkText}`,
357
- html: `${bodyHtml}\n${linkHtml}`,
358
- };
359
- }
360
352
  return { text: bodyText, html: bodyHtml };
361
353
  }
362
354
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "3.12.0",
3
+ "version": "3.12.2",
4
4
  "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
5
5
  "keywords": [
6
6
  "indiekit",