Fix concurrent unfollowing decrementing follower count more than once (#18527)

This commit is contained in:
Eugen Rochko 2022-05-26 22:14:47 +02:00 committed by GitHub
parent 8a9acbe604
commit 52f4e834f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,8 @@
class UnfollowService < BaseService class UnfollowService < BaseService
include Payloadable include Payloadable
include Redisable
include Lockable
# Unfollow and notify the remote user # Unfollow and notify the remote user
# @param [Account] source_account Where to unfollow from # @param [Account] source_account Where to unfollow from
@ -13,8 +15,10 @@ class UnfollowService < BaseService
@target_account = target_account @target_account = target_account
@options = options @options = options
with_lock("relationship:#{[source_account.id, target_account.id].sort.join(':')}") do
unfollow! || undo_follow_request! unfollow! || undo_follow_request!
end end
end
private private