From 10865168bf912338f90754721c7be38359d205d8 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 22 Oct 2023 22:49:24 +0200 Subject: [PATCH] [backend] Fix UserListJoining delete query on unfollow --- packages/backend/src/services/following/delete.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/services/following/delete.ts b/packages/backend/src/services/following/delete.ts index 7a5d43395..fa86d33ec 100644 --- a/packages/backend/src/services/following/delete.ts +++ b/packages/backend/src/services/following/delete.ts @@ -45,7 +45,10 @@ export default async function ( return; } - await UserListJoinings.delete({ userId: followee.id, userList: { userId: follower.id } }); + const ids = await UserListJoinings.find({ where: { userId: followee.id, userList: { userId: follower.id } }, select: ["id"] }) + .then(p => p.map(x => x.id)); + + if (ids.length > 0) await UserListJoinings.delete(ids); await Followings.delete(following.id); decrementFollowing(follower, followee);