From 44de1ad74878b4c6c4c067e4713110c84db2386d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Aug 2022 19:05:22 -0600 Subject: [PATCH 1/2] Update unfollow api endpoint to only decrement when appropriate, fixes #3539 --- app/Http/Controllers/Api/ApiV1Controller.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index 314e7f1c1..148ad22f4 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -753,7 +753,9 @@ class ApiV1Controller extends Controller 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) ->whereFollowingId($target->id) From 49d43e06e2a150d4649e1894058e8f4862afa8b9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 1 Aug 2022 19:06:02 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37acbe94e..d285079db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ - Fix NotificationService bug returning html response on /api/v1/notifications endpoint when a notification id belonging to a deleted account is rendered by checking AccountService before NotificationTransformer. ([734b30e5](https://github.com/pixelfed/pixelfed/commit/734b30e5)) - Hydrate `favourited` and `reblogged` state on v1 context endpoint ([abb4f7e1](https://github.com/pixelfed/pixelfed/commit/abb4f7e1)) - Improve admin dashboard by moving expensive stats to its page and loading stats and recent data async on the dashboard home page ([9d52b9c2](https://github.com/pixelfed/pixelfed/commit/9d52b9c2)) +- Update unfollow api endpoint to only decrement when appropriate, fixes #3539 ([44de1ad7](https://github.com/pixelfed/pixelfed/commit/44de1ad7)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.3 (2022-05-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.2...v0.11.3)