@rmdes/indiekit-endpoint-activitypub 1.0.16 → 1.0.18
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 +2 -0
- package/lib/inbox-listeners.js +41 -3
- package/package.json +1 -1
- package/views/activitypub-dashboard.njk +31 -22
package/index.js
CHANGED
|
@@ -166,6 +166,8 @@ export default class ActivityPubEndpoint {
|
|
|
166
166
|
router.use((req, res, next) => {
|
|
167
167
|
if (!self._fedifyMiddleware) return next();
|
|
168
168
|
if (req.method !== "GET" && req.method !== "HEAD") return next();
|
|
169
|
+
// Skip Fedify for admin routes — handled by authenticated router
|
|
170
|
+
if (req.path.startsWith("/admin")) return next();
|
|
169
171
|
return self._fedifyMiddleware(req, res, next);
|
|
170
172
|
});
|
|
171
173
|
|
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.18",
|
|
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",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
{# Progress bar #}
|
|
40
40
|
<div style="background: var(--color-offset); border-radius: 4px; height: 1.5rem; margin-block-end: var(--space-m); overflow: hidden;">
|
|
41
41
|
<div
|
|
42
|
-
x-bind:style="'width:' + progress + '%;
|
|
43
|
-
style="width: {{ refollowStatus.progressPercent }}%;
|
|
42
|
+
x-bind:style="'width:' + progress + '%; height: 100%; transition: width 0.5s ease; background: var(--color-primary);'"
|
|
43
|
+
style="width: {{ refollowStatus.progressPercent }}%; height: 100%; transition: width 0.5s ease; background: var(--color-primary);">
|
|
44
44
|
</div>
|
|
45
45
|
</div>
|
|
46
46
|
|
|
@@ -48,39 +48,42 @@
|
|
|
48
48
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-s); margin-block-end: var(--space-m);">
|
|
49
49
|
<div style="padding: var(--space-s); background: var(--color-offset); border-radius: 4px; text-align: center;">
|
|
50
50
|
<div style="font-size: var(--font-size-xl);" x-text="remaining">{{ refollowStatus.remaining }}</div>
|
|
51
|
-
<div style="font-size: var(--font-size-s); color: var(--color-
|
|
51
|
+
<div style="font-size: var(--font-size-s); color: var(--color-outline);">{{ __("activitypub.refollow.remaining") }}</div>
|
|
52
52
|
</div>
|
|
53
53
|
<div style="padding: var(--space-s); background: var(--color-offset); border-radius: 4px; text-align: center;">
|
|
54
54
|
<div style="font-size: var(--font-size-xl);" x-text="sent">{{ refollowStatus.sent }}</div>
|
|
55
|
-
<div style="font-size: var(--font-size-s); color: var(--color-
|
|
55
|
+
<div style="font-size: var(--font-size-s); color: var(--color-outline);">{{ __("activitypub.refollow.awaitingAccept") }}</div>
|
|
56
56
|
</div>
|
|
57
57
|
<div style="padding: var(--space-s); background: var(--color-offset); border-radius: 4px; text-align: center;">
|
|
58
58
|
<div style="font-size: var(--font-size-xl);" x-text="federated">{{ refollowStatus.federated }}</div>
|
|
59
|
-
<div style="font-size: var(--font-size-s); color: var(--color-
|
|
59
|
+
<div style="font-size: var(--font-size-s); color: var(--color-outline);">{{ __("activitypub.refollow.accepted") }}</div>
|
|
60
60
|
</div>
|
|
61
61
|
<div style="padding: var(--space-s); background: var(--color-offset); border-radius: 4px; text-align: center;">
|
|
62
62
|
<div style="font-size: var(--font-size-xl);" x-text="failed">{{ refollowStatus.failed }}</div>
|
|
63
|
-
<div style="font-size: var(--font-size-s); color: var(--color-
|
|
63
|
+
<div style="font-size: var(--font-size-s); color: var(--color-outline);">{{ __("activitypub.refollow.failed") }}</div>
|
|
64
64
|
</div>
|
|
65
65
|
</div>
|
|
66
66
|
|
|
67
67
|
{# Status + controls #}
|
|
68
68
|
<div style="display: flex; align-items: center; gap: var(--space-s);">
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<button type="submit" class="button" style="font-size: var(--font-size-s);">{{ __("activitypub.refollow.resume") }}</button>
|
|
77
|
-
</form>
|
|
78
|
-
{% endif %}
|
|
69
|
+
<span class="badge" x-text="statusLabel">{{ __("activitypub.refollow.status." + refollowStatus.status) }}</span>
|
|
70
|
+
<form x-show="status === 'running'" method="post" action="{{ mountPath }}/admin/refollow/pause" x-on:submit.prevent="pause" style="display: none;">
|
|
71
|
+
<button type="submit" class="button" style="font-size: var(--font-size-s);">{{ __("activitypub.refollow.pause") }}</button>
|
|
72
|
+
</form>
|
|
73
|
+
<form x-show="status === 'paused'" method="post" action="{{ mountPath }}/admin/refollow/resume" x-on:submit.prevent="resume" style="display: none;">
|
|
74
|
+
<button type="submit" class="button" style="font-size: var(--font-size-s);">{{ __("activitypub.refollow.resume") }}</button>
|
|
75
|
+
</form>
|
|
79
76
|
</div>
|
|
80
77
|
</section>
|
|
81
78
|
|
|
82
79
|
<script>
|
|
83
80
|
function refollowProgress(mountPath) {
|
|
81
|
+
const statusLabels = {
|
|
82
|
+
idle: '{{ __("activitypub.refollow.status.idle") }}',
|
|
83
|
+
running: '{{ __("activitypub.refollow.status.running") }}',
|
|
84
|
+
paused: '{{ __("activitypub.refollow.status.paused") }}',
|
|
85
|
+
completed: '{{ __("activitypub.refollow.status.completed") }}'
|
|
86
|
+
};
|
|
84
87
|
return {
|
|
85
88
|
progress: {{ refollowStatus.progressPercent }},
|
|
86
89
|
remaining: {{ refollowStatus.remaining }},
|
|
@@ -89,6 +92,9 @@
|
|
|
89
92
|
failed: {{ refollowStatus.failed }},
|
|
90
93
|
status: '{{ refollowStatus.status }}',
|
|
91
94
|
interval: null,
|
|
95
|
+
get statusLabel() {
|
|
96
|
+
return statusLabels[this.status] || this.status;
|
|
97
|
+
},
|
|
92
98
|
init() {
|
|
93
99
|
if (this.status === 'running' || this.status === 'paused') {
|
|
94
100
|
this.interval = setInterval(() => this.poll(), 10000);
|
|
@@ -100,6 +106,7 @@
|
|
|
100
106
|
async poll() {
|
|
101
107
|
try {
|
|
102
108
|
const res = await fetch(mountPath + '/admin/refollow/status');
|
|
109
|
+
if (!res.ok) return;
|
|
103
110
|
const data = await res.json();
|
|
104
111
|
this.progress = data.progressPercent;
|
|
105
112
|
this.remaining = data.remaining;
|
|
@@ -113,14 +120,16 @@
|
|
|
113
120
|
} catch {}
|
|
114
121
|
},
|
|
115
122
|
async pause() {
|
|
116
|
-
await fetch(mountPath + '/admin/refollow/pause', { method: 'POST' });
|
|
117
|
-
this.status = 'paused';
|
|
123
|
+
const res = await fetch(mountPath + '/admin/refollow/pause', { method: 'POST' });
|
|
124
|
+
if (res.ok) this.status = 'paused';
|
|
118
125
|
},
|
|
119
126
|
async resume() {
|
|
120
|
-
await fetch(mountPath + '/admin/refollow/resume', { method: 'POST' });
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
const res = await fetch(mountPath + '/admin/refollow/resume', { method: 'POST' });
|
|
128
|
+
if (res.ok) {
|
|
129
|
+
this.status = 'running';
|
|
130
|
+
if (!this.interval) {
|
|
131
|
+
this.interval = setInterval(() => this.poll(), 10000);
|
|
132
|
+
}
|
|
124
133
|
}
|
|
125
134
|
}
|
|
126
135
|
};
|