fix: #13392, regression from c6f2c87, unable to unfollow from pending follows

This commit is contained in:
Julian Lam
2025-05-08 13:55:17 -04:00
parent a9a5ab5e4b
commit 401ff797c9

View File

@@ -84,13 +84,22 @@ activitypubApi.unfollow = enabledCheck(async (caller, { type, id, actor }) => {
throw new Error('[[error:activitypub.invalid-id]]'); throw new Error('[[error:activitypub.invalid-id]]');
} }
actor = actor.includes('@') ? await user.getUidByUserslug(actor) : actor; if (actor.includes('@')) {
const [handle, isFollowing] = await Promise.all([ const [uid, cid] = await Promise.all([
user.getUserField(actor, 'username'), user.getUidByUserslug(actor),
db.isSortedSetMember(type === 'uid' ? `followingRemote:${id}` : `cid:${id}:following`, actor), categories.getCidByHandle(actor),
]); ]);
if (!isFollowing) { // already not following 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 && !isPending) { // already not following/pending
return; return;
} }