From 02e32c70c704bced445542ca4a716a816def53b3 Mon Sep 17 00:00:00 2001 From: pancakes Date: Fri, 1 Nov 2024 22:28:40 +1000 Subject: [PATCH] [backend/api] Check if user is following instead of if user exists --- Iceshrimp.Backend/Controllers/Web/UserController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Web/UserController.cs b/Iceshrimp.Backend/Controllers/Web/UserController.cs index cd55ec2b..fef56392 100644 --- a/Iceshrimp.Backend/Controllers/Web/UserController.cs +++ b/Iceshrimp.Backend/Controllers/Web/UserController.cs @@ -150,8 +150,9 @@ public class UserController( if (user.Id == id) throw GracefulException.BadRequest("You cannot unfollow yourself"); - var follower = await db.Users - .Where(p => p.Id == id) + var follower = await db.Followings + .Where(p => p.FolloweeId == user.Id && p.FollowerId == id) + .Select(p => p.Follower) .IncludeCommonProperties() .PrecomputeRelationshipData(user) .FirstOrDefaultAsync() ??