fix: append permalink at read time in serializeStatus, not write time
Permalinks added at write time to ap_timeline get wiped by startup backfill and timeline cleanup (which delete and re-create entries). Moving to read time in serializeStatus means the link is always present regardless of how or when the timeline entry was created. Detects own posts via _localPublicationUrl match on author.url. Skips if the content already contains the URL (no duplicates).
This commit is contained in:
@@ -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, "<").replace(/>/g, ">");
|
||||
content += `\n<p>\u{1F517} <a href="${escaped}">${escaped}</a></p>`;
|
||||
}
|
||||
const spoilerText = item.summary || "";
|
||||
const sensitive = item.sensitive || false;
|
||||
const visibility = item.visibility || "public";
|
||||
|
||||
+1
-8
@@ -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, ">").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>`;
|
||||
}
|
||||
// Permalink is appended at read time by serializeStatus, not here.
|
||||
|
||||
const timelineItem = {
|
||||
uid: properties.url,
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user