From 401ff797c91217c4887b86f013f038b7d4e09b13 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 8 May 2025 13:55:17 -0400 Subject: [PATCH] fix: #13392, regression from c6f2c87, unable to unfollow from pending follows --- src/api/activitypub.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/api/activitypub.js b/src/api/activitypub.js index ed9e6f2f64..2752a50bc6 100644 --- a/src/api/activitypub.js +++ b/src/api/activitypub.js @@ -84,13 +84,22 @@ activitypubApi.unfollow = enabledCheck(async (caller, { type, id, actor }) => { throw new Error('[[error:activitypub.invalid-id]]'); } - actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor; - const [handle, isFollowing] = await Promise.all([ + if (actor.includes('@')) { + const [uid, cid] = await Promise.all([ + user.getUidByUserslug(actor), + categories.getCidByHandle(actor), + ]); + + actor = uid || cid; + } + + const [handle, isFollowing, isPending] = await Promise.all([ user.getUserField(actor, 'username'), db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor), + db.isSortedSetMember(`followRequests:${type === 'uid' ? 'uid' : 'cid'}.${id}`, actor), ]); - if (!isFollowing) { // already not following + if (!isFollowing && !isPending) { // already not following/pending return; }