[backend/api] Check if user is following instead of if user exists
This commit is contained in:
parent
ea5408c182
commit
02e32c70c7
1 changed files with 3 additions and 2 deletions
|
@ -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() ??
|
||||||
|
|
Loading…
Add table
Reference in a new issue