@rmdes/indiekit-endpoint-activitypub 1.0.16 → 1.0.17
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/inbox-listeners.js +41 -3
- package/package.json +1 -1
package/lib/inbox-listeners.js
CHANGED
|
@@ -332,16 +332,54 @@ async function logActivity(collections, storeRaw, record) {
|
|
|
332
332
|
let _apChannelId = null;
|
|
333
333
|
|
|
334
334
|
/**
|
|
335
|
-
* Look up the ActivityPub channel's ObjectId
|
|
335
|
+
* Look up (or auto-create) the ActivityPub channel's ObjectId.
|
|
336
|
+
* Cached after first successful call.
|
|
337
|
+
*
|
|
338
|
+
* The channel is created with `userId: "default"` so it appears in the
|
|
339
|
+
* Microsub reader UI alongside user-created channels.
|
|
340
|
+
*
|
|
336
341
|
* @param {object} collections - MongoDB collections
|
|
337
342
|
* @returns {Promise<import("mongodb").ObjectId|null>}
|
|
338
343
|
*/
|
|
339
344
|
async function getApChannelId(collections) {
|
|
340
345
|
if (_apChannelId) return _apChannelId;
|
|
341
|
-
|
|
346
|
+
if (!collections.microsub_channels) return null;
|
|
347
|
+
|
|
348
|
+
let channel = await collections.microsub_channels.findOne({
|
|
342
349
|
uid: "activitypub",
|
|
343
350
|
});
|
|
344
|
-
|
|
351
|
+
|
|
352
|
+
if (!channel) {
|
|
353
|
+
// Auto-create the channel with the same fields the Microsub plugin uses
|
|
354
|
+
const maxOrderDoc = await collections.microsub_channels
|
|
355
|
+
.find({ userId: "default" })
|
|
356
|
+
.sort({ order: -1 })
|
|
357
|
+
.limit(1)
|
|
358
|
+
.toArray();
|
|
359
|
+
const order = maxOrderDoc.length > 0 ? maxOrderDoc[0].order + 1 : 0;
|
|
360
|
+
|
|
361
|
+
const doc = {
|
|
362
|
+
uid: "activitypub",
|
|
363
|
+
name: "Fediverse",
|
|
364
|
+
userId: "default",
|
|
365
|
+
order,
|
|
366
|
+
settings: { excludeTypes: [], excludeRegex: null },
|
|
367
|
+
createdAt: new Date().toISOString(),
|
|
368
|
+
updatedAt: new Date().toISOString(),
|
|
369
|
+
};
|
|
370
|
+
await collections.microsub_channels.insertOne(doc);
|
|
371
|
+
channel = doc;
|
|
372
|
+
console.info("[ActivityPub] Auto-created Microsub channel 'Fediverse'");
|
|
373
|
+
} else if (!channel.userId) {
|
|
374
|
+
// Fix existing channel missing userId (created by earlier version)
|
|
375
|
+
await collections.microsub_channels.updateOne(
|
|
376
|
+
{ _id: channel._id },
|
|
377
|
+
{ $set: { userId: "default" } },
|
|
378
|
+
);
|
|
379
|
+
console.info("[ActivityPub] Fixed Microsub channel: set userId to 'default'");
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
_apChannelId = channel._id;
|
|
345
383
|
return _apChannelId;
|
|
346
384
|
}
|
|
347
385
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
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",
|