mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-16 23:27:27 +01:00
Fix concurrent unfollowing decrementing follower count more than once
This commit is contained in:
parent
a3909514bf
commit
104fdaf446
@ -13,7 +13,13 @@ class UnfollowService < BaseService
|
||||
@target_account = target_account
|
||||
@options = options
|
||||
|
||||
unfollow! || undo_follow_request!
|
||||
RedisLock.acquire(redis: Redis.current, key: "relationship:#{[source_account.id, target_account.id].sort.join(':')}", autorelease: 90.seconds) do |lock|
|
||||
if lock.acquired?
|
||||
unfollow! || undo_follow_request!
|
||||
else
|
||||
raise Mastodon::RaceConditionError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
Loading…
x
Reference in New Issue
Block a user