diff options
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/distribution_worker.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/app/workers/distribution_worker.rb b/app/workers/distribution_worker.rb index 474b4daaf..59cdbc7b2 100644 --- a/app/workers/distribution_worker.rb +++ b/app/workers/distribution_worker.rb @@ -3,14 +3,11 @@ class DistributionWorker include Sidekiq::Worker include Redisable + include Lockable def perform(status_id, options = {}) - RedisLock.acquire(redis: redis, key: "distribute:#{status_id}", autorelease: 5.minutes.seconds) do |lock| - if lock.acquired? - FanOutOnWriteService.new.call(Status.find(status_id), **options.symbolize_keys) - else - raise Mastodon::RaceConditionError - end + with_lock("distribute:#{status_id}") do + FanOutOnWriteService.new.call(Status.find(status_id), **options.symbolize_keys) end rescue ActiveRecord::RecordNotFound true |