Commit 104fdaf4 authored by Eugen Rochko's avatar Eugen Rochko
Browse files

Fix concurrent unfollowing decrementing follower count more than once

parent a3909514
Showing with 7 additions and 1 deletion
+7 -1
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment