summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-05-26 22:14:47 +0200
committerGitHub <noreply@github.com>2022-05-26 22:14:47 +0200
commit52f4e834f293c9fdbf5805639d022ac4e3856b75 (patch)
tree8a7d3be0551f159957e5c0de80c89db23f01f2e7
parent8a9acbe604667215c9589154d72b3f313755c210 (diff)
Fix concurrent unfollowing decrementing follower count more than once (#18527)
-rw-r--r--app/services/unfollow_service.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/services/unfollow_service.rb b/app/services/unfollow_service.rb
index 151f3674fd6..d83a60e4e72 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