Skip to content

Node.js based forum software built for the modern web

Merge branch 'master' into develop

Julian Lamd5349b39f5c8
diff --cc src/api/activitypub.js
index 4701c0ca51,2752a50bc6..43dad015b1
--- a/src/api/activitypub.js
+++ b/src/api/activitypub.js
@@@ -43,9 -44,19 +44,16 @@@ activitypubApi.follow = enabledCheck(as
throw new Error('[[error:activitypub.invalid-id]]');
}
- actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
+ if (actor.includes('@')) {
+ const [uid, cid] = await Promise.all([
+ user.getUidByUserslug(actor),
+ categories.getCidByHandle(actor),
+ ]);
+
+ actor = uid || cid;
+ }
- const [handle, isFollowing] = await Promise.all([
- user.getUserField(actor, 'username'),
- db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor),
- ]);
+ const isFollowing = await db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor);
if (isFollowing) { // already following
return;
}
@@@ -73,10 -84,22 +81,21 @@@ activitypubApi.unfollow = enabledCheck(
throw new Error('[[error:activitypub.invalid-id]]');
}
- actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor;
+ if (actor.includes('@')) {
+ const [uid, cid] = await Promise.all([
+ user.getUidByUserslug(actor),
+ categories.getCidByHandle(actor),
+ ]);
- const isFollowing = await db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor);
- if (!isFollowing) { // already not following
+ actor = uid || cid;
+ }
+
- const [handle, isFollowing, isPending] = await Promise.all([
- user.getUserField(actor, 'username'),
++ const [isFollowing, isPending] = await Promise.all([
+ db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor),
+ db.isSortedSetMember(`followRequests:${type === 'uid' ? 'uid' : 'cid'}.${id}`, actor),
+ ]);
+
+ if (!isFollowing && !isPending) { // already not following/pending
return;
}