From: Eugen Rochko Date: Thu, 26 May 2022 20:14:47 +0000 (+0200) Subject: Fix concurrent unfollowing decrementing follower count more than once (#18527) X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=2850503c6f6cbcc45e8cbdd693d906a505ceef8b;p=mastodon.git Fix concurrent unfollowing decrementing follower count more than once (#18527) --- diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb index 151f3674f..d83a60e4e 100644 --- a/app/services/unfollow_service.rb +++ b/app/services/unfollow_service.rb @@ -2,6 +2,8 @@ class UnfollowService < BaseService include Payloadable + include Redisable + include Lockable # Unfollow and notify the remote user # @param [Account] source_account Where to unfollow from @@ -13,7 +15,9 @@ class UnfollowService < BaseService @target_account = target_account @options = options - unfollow! || undo_follow_request! + with_lock("relationship:#{[source_account.id, target_account.id].sort.join(':')}") do + unfollow! || undo_follow_request! + end end private