@rmdes/indiekit-endpoint-activitypub 1.0.0 → 1.0.1

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
@@ -87,6 +87,30 @@ export default class ActivityPubEndpoint {
87
87
  return self._fedifyMiddleware(req, res, next);
88
88
  });
89
89
 
90
+ // Catch-all for federation paths that Fedify didn't handle (e.g. GET
91
+ // on inbox). Without this, they fall through to Indiekit's auth
92
+ // middleware and redirect to the login page.
93
+ router.all("/users/:identifier/inbox", (req, res) => {
94
+ res
95
+ .status(405)
96
+ .set("Allow", "POST")
97
+ .type("application/activity+json")
98
+ .json({
99
+ error: "Method Not Allowed",
100
+ message: "The inbox only accepts POST requests",
101
+ });
102
+ });
103
+ router.all("/inbox", (req, res) => {
104
+ res
105
+ .status(405)
106
+ .set("Allow", "POST")
107
+ .type("application/activity+json")
108
+ .json({
109
+ error: "Method Not Allowed",
110
+ message: "The shared inbox only accepts POST requests",
111
+ });
112
+ });
113
+
90
114
  return router;
91
115
  }
92
116
 
@@ -7,14 +7,18 @@
7
7
 
8
8
  import {
9
9
  Accept,
10
+ Add,
10
11
  Announce,
12
+ Block,
11
13
  Create,
12
14
  Delete,
13
15
  Follow,
14
16
  Like,
15
17
  Move,
16
18
  Note,
19
+ Remove,
17
20
  Undo,
21
+ Update,
18
22
  } from "@fedify/fedify";
19
23
 
20
24
  /**
@@ -201,6 +205,46 @@ export function registerInboxListeners(inboxChain, options) {
201
205
  objectUrl: newActorUrl,
202
206
  summary: `${oldActorUrl} moved to ${newActorUrl}`,
203
207
  });
208
+ })
209
+ .on(Update, async (ctx, update) => {
210
+ // Remote actor updated their profile — refresh stored follower data
211
+ const actorObj = await update.getActor();
212
+ const actorUrl = actorObj?.id?.href || "";
213
+ if (!actorUrl) return;
214
+
215
+ const existing = await collections.ap_followers.findOne({ actorUrl });
216
+ if (existing) {
217
+ await collections.ap_followers.updateOne(
218
+ { actorUrl },
219
+ {
220
+ $set: {
221
+ name:
222
+ actorObj.name?.toString() ||
223
+ actorObj.preferredUsername?.toString() ||
224
+ actorUrl,
225
+ handle: actorObj.preferredUsername?.toString() || "",
226
+ avatar: actorObj.icon
227
+ ? (await actorObj.icon)?.url?.href || ""
228
+ : "",
229
+ updatedAt: new Date().toISOString(),
230
+ },
231
+ },
232
+ );
233
+ }
234
+ })
235
+ .on(Block, async (ctx, block) => {
236
+ // Remote actor blocked us — remove them from followers
237
+ const actorObj = await block.getActor();
238
+ const actorUrl = actorObj?.id?.href || "";
239
+ if (actorUrl) {
240
+ await collections.ap_followers.deleteOne({ actorUrl });
241
+ }
242
+ })
243
+ .on(Add, async () => {
244
+ // Mastodon uses Add for pinning posts to featured collections — safe to ignore
245
+ })
246
+ .on(Remove, async () => {
247
+ // Mastodon uses Remove for unpinning posts from featured collections — safe to ignore
204
248
  });
205
249
  }
206
250
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
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",