Skip to content

Node.js based forum software built for the modern web

fix(activitypub): handle FediBuzz Accept with actor document as object

Julian Lam40ca8efc56c0
diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js
index b7313f6d45..2a63f40b36 100644
--- a/src/activitypub/inbox.js
+++ b/src/activitypub/inbox.js
@@ -840,12 +840,19 @@ inbox.isFollowed = async (actorId, uid) => {
inbox.accept = async (req) => {
const { actor, object } = req.body;
- const { type } = object;
+ let { type } = object;
- const { type: localType, id } = await helpers.resolveLocalId(object.actor);
if (object.id === `${nconf.get('url')}/actor`) {
- return activitypub.relays.handshake(req.body);
- } else if (!['user', 'category', 'application'].includes(localType)) {
+ // If the accepting actor is a known relay, handle as relay handshake
+ const isRelay = await db.isSortedSetMember('relays:createtime', actor);
+ if (isRelay) {
+ return activitypub.relays.handshake(req.body);
+ }
+ type = 'Follow'; // treat as Follow acceptance for hashtag/instance follows
+ }
+
+ const { type: localType, id } = await helpers.resolveLocalId(object.actor || object.id);
+ if (!['user', 'category', 'application'].includes(localType)) {
throw new Error('[[error:invalid-data]]');
}