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]]');
}
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;
}