diff options
author | Reverite <github@reverite.sh> | 2019-03-21 15:35:55 -0700 |
---|---|---|
committer | Reverite <github@reverite.sh> | 2019-03-21 15:35:55 -0700 |
commit | 592735fd80acd0aeffb5a5674255ed48d7a8db0b (patch) | |
tree | 0eefc67f624a07df0af860edecd68d5dc64c7ee9 /app/services/remove_status_service.rb | |
parent | 75eeb003b09c53d3b4e98046d1c20b0ad8a887bb (diff) | |
parent | bde9196b70299405ebe9b16500b7a3f65539b2c3 (diff) |
Merge remote-tracking branch 'glitch/master' into production
Diffstat (limited to 'app/services/remove_status_service.rb')
-rw-r--r-- | app/services/remove_status_service.rb | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 7eec11ddf..6e4998e07 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -14,17 +14,23 @@ class RemoveStatusService < BaseService @stream_entry = status.stream_entry @options = options - remove_from_self if status.account.local? - remove_from_followers - remove_from_lists - remove_from_affected - remove_reblogs - remove_from_hashtags - remove_from_public - remove_from_media if status.media_attachments.any? - remove_from_direct if status.direct_visibility? - - @status.destroy! + RedisLock.acquire(lock_options) do |lock| + if lock.acquired? + remove_from_self if status.account.local? + remove_from_followers + remove_from_lists + remove_from_affected + remove_reblogs + remove_from_hashtags + remove_from_public + remove_from_media if status.media_attachments.any? + remove_from_direct if status.direct_visibility? + + @status.destroy! + else + raise Mastodon::RaceConditionError + end + end # There is no reason to send out Undo activities when the # cause is that the original object has been removed, since @@ -164,4 +170,8 @@ class RemoveStatusService < BaseService end Redis.current.publish("timeline:direct:#{@account.id}", @payload) if @account.local? end + + def lock_options + { redis: Redis.current, key: "distribute:#{@status.id}" } + end end |