Update unfollow api endpoint to only decrement when appropriate, fixes #3539

This commit is contained in:
Daniel Supernault 2022-08-01 19:05:22 -06:00
parent 7863120292
commit 44de1ad748
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 3 additions and 1 deletions

View File

@ -753,7 +753,9 @@ class ApiV1Controller extends Controller
abort(400, 'You can only follow or unfollow ' . Follower::FOLLOW_PER_HOUR . ' users per hour'); abort(400, 'You can only follow or unfollow ' . Follower::FOLLOW_PER_HOUR . ' users per hour');
} }
$user->profile->decrement('following_count'); if($user->profile->following_count) {
$user->profile->decrement('following_count');
}
FollowRequest::whereFollowerId($user->profile_id) FollowRequest::whereFollowerId($user->profile_id)
->whereFollowingId($target->id) ->whereFollowingId($target->id)