@rmdes/indiekit-endpoint-activitypub 3.12.2 → 3.12.3
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.
- package/lib/mastodon/entities/status.js +12 -7
- package/lib/syndicator.js +28 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { serializeAccount } from "./account.js";
|
|
17
17
|
import { sanitizeHtml } from "./sanitize.js";
|
|
18
|
+
import { remoteActorId } from "../helpers/id-mapping.js";
|
|
18
19
|
|
|
19
20
|
// Module-level defaults set once at startup via setLocalIdentity()
|
|
20
21
|
let _localPublicationUrl = "";
|
|
@@ -178,13 +179,17 @@ export function serializeStatus(item, { baseUrl, favouritedIds, rebloggedIds, bo
|
|
|
178
179
|
url: `${baseUrl}/tags/${encodeURIComponent(tag)}`,
|
|
179
180
|
}));
|
|
180
181
|
|
|
181
|
-
// Mentions
|
|
182
|
-
const mentions = (item.mentions || []).map((m) =>
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
// Mentions — use actorUrl for deterministic ID, parse acct from handle
|
|
183
|
+
const mentions = (item.mentions || []).map((m) => {
|
|
184
|
+
const handle = (m.name || "").replace(/^@/, "");
|
|
185
|
+
const parts = handle.split("@");
|
|
186
|
+
return {
|
|
187
|
+
id: m.actorUrl ? remoteActorId(m.actorUrl) : "0",
|
|
188
|
+
username: parts[0] || handle,
|
|
189
|
+
url: m.url || m.actorUrl || "",
|
|
190
|
+
acct: handle,
|
|
191
|
+
};
|
|
192
|
+
});
|
|
188
193
|
|
|
189
194
|
// Custom emojis
|
|
190
195
|
const emojis = (item.emojis || []).map((e) => ({
|
package/lib/syndicator.js
CHANGED
|
@@ -227,11 +227,39 @@ export function createSyndicator(plugin) {
|
|
|
227
227
|
const content = buildTimelineContent(properties);
|
|
228
228
|
// Permalink is appended at read time by serializeStatus, not here.
|
|
229
229
|
|
|
230
|
+
// Linkify @mentions in content using resolved WebFinger data.
|
|
231
|
+
// This ensures the ap_timeline HTML has proper <a> links for
|
|
232
|
+
// mentions, matching what the federated AS2 activity contains.
|
|
233
|
+
if (resolvedMentions.length > 0 && content.html) {
|
|
234
|
+
const { default: jf2Mod } = await import("./jf2-to-as2.js");
|
|
235
|
+
// Import linkifyMentions — it's not exported, so inline the logic
|
|
236
|
+
for (const { handle, profileUrl, actorUrl } of resolvedMentions) {
|
|
237
|
+
const escaped = handle.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
238
|
+
const pattern = new RegExp(`(?<!["\\/\\w])@${escaped}(?![\\w])`, "gi");
|
|
239
|
+
const parts = handle.split("@");
|
|
240
|
+
const url = profileUrl || (actorUrl ? actorUrl : `https://${parts[1]}/@${parts[0]}`);
|
|
241
|
+
content.html = content.html.replace(
|
|
242
|
+
pattern,
|
|
243
|
+
`<a href="${url}" class="mention" rel="nofollow noopener" target="_blank">@${handle}</a>`,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Store resolved mentions for Mastodon API serialization
|
|
249
|
+
const timelineMentions = resolvedMentions
|
|
250
|
+
.filter(m => m.actorUrl)
|
|
251
|
+
.map(m => ({
|
|
252
|
+
name: `@${m.handle}`,
|
|
253
|
+
url: m.profileUrl || m.actorUrl,
|
|
254
|
+
actorUrl: m.actorUrl,
|
|
255
|
+
}));
|
|
256
|
+
|
|
230
257
|
const timelineItem = {
|
|
231
258
|
uid: properties.url,
|
|
232
259
|
url: properties.url,
|
|
233
260
|
type: mapPostType(properties["post-type"]),
|
|
234
261
|
content,
|
|
262
|
+
mentions: timelineMentions,
|
|
235
263
|
author: {
|
|
236
264
|
name: profile?.name || handle,
|
|
237
265
|
url: profile?.url || plugin._publicationUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.3",
|
|
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",
|