@rmdes/indiekit-endpoint-activitypub 3.5.6 → 3.5.7

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/index.js CHANGED
@@ -2,6 +2,7 @@ import express from "express";
2
2
 
3
3
  import { setupFederation, buildPersonActor } from "./lib/federation-setup.js";
4
4
  import { createMastodonRouter } from "./lib/mastodon/router.js";
5
+ import { setLocalIdentity } from "./lib/mastodon/entities/status.js";
5
6
  import { initRedisCache } from "./lib/redis-cache.js";
6
7
  import { lookupWithSecurity } from "./lib/lookup-helpers.js";
7
8
  import {
@@ -1492,6 +1493,9 @@ export default class ActivityPubEndpoint {
1492
1493
  routesPublic: this.contentNegotiationRoutes,
1493
1494
  });
1494
1495
 
1496
+ // Set local identity for own-post detection in status serialization
1497
+ setLocalIdentity(this._publicationUrl, this.options.actor?.handle || "user");
1498
+
1495
1499
  // Mastodon Client API — virtual endpoint at root
1496
1500
  // Mastodon-compatible clients (Phanpy, Elk, etc.) expect /api/v1/*,
1497
1501
  // /api/v2/*, /oauth/* at the domain root, not under /activitypub.
@@ -16,6 +16,21 @@
16
16
  import { serializeAccount } from "./account.js";
17
17
  import { sanitizeHtml } from "./sanitize.js";
18
18
 
19
+ // Module-level defaults set once at startup via setLocalIdentity()
20
+ let _localPublicationUrl = "";
21
+ let _localHandle = "";
22
+
23
+ /**
24
+ * Set the local identity for own-post detection.
25
+ * Called once during plugin init.
26
+ * @param {string} publicationUrl - e.g. "https://rmendes.net/"
27
+ * @param {string} handle - e.g. "rick"
28
+ */
29
+ export function setLocalIdentity(publicationUrl, handle) {
30
+ _localPublicationUrl = publicationUrl;
31
+ _localHandle = handle;
32
+ }
33
+
19
34
  /**
20
35
  * Serialize an ap_timeline document as a Mastodon Status entity.
21
36
  *
@@ -207,7 +222,11 @@ export function serializeStatus(item, { baseUrl, favouritedIds, rebloggedIds, bo
207
222
  reblog: null,
208
223
  application: null,
209
224
  account: item.author
210
- ? serializeAccount(item.author, { baseUrl })
225
+ ? serializeAccount(item.author, {
226
+ baseUrl,
227
+ isLocal: !!(_localPublicationUrl && item.author.url === _localPublicationUrl),
228
+ handle: _localHandle,
229
+ })
211
230
  : null,
212
231
  media_attachments: mediaAttachments,
213
232
  mentions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "3.5.6",
3
+ "version": "3.5.7",
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",