Fix concurrent unfollowing decrementing follower count more than once
This commit is contained in:
parent
a3909514bf
commit
104fdaf446
1 changed files with 7 additions and 1 deletions
|
@ -13,7 +13,13 @@ class UnfollowService < BaseService
|
||||||
@target_account = target_account
|
@target_account = target_account
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
|
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!
|
unfollow! || undo_follow_request!
|
||||||
|
else
|
||||||
|
raise Mastodon::RaceConditionError
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue