[backend/api] Check if user is following instead of if user exists

This commit is contained in:
pancakes 2024-11-01 22:28:40 +10:00 committed by Iceshrimp development
parent ea5408c182
commit 02e32c70c7

View file

@ -150,8 +150,9 @@ public class UserController(
if (user.Id == id) if (user.Id == id)
throw GracefulException.BadRequest("You cannot unfollow yourself"); throw GracefulException.BadRequest("You cannot unfollow yourself");
var follower = await db.Users var follower = await db.Followings
.Where(p => p.Id == id) .Where(p => p.FolloweeId == user.Id && p.FollowerId == id)
.Select(p => p.Follower)
.IncludeCommonProperties() .IncludeCommonProperties()
.PrecomputeRelationshipData(user) .PrecomputeRelationshipData(user)
.FirstOrDefaultAsync() ?? .FirstOrDefaultAsync() ??