diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-16 09:42:32 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-05-16 09:42:32 +0200 |
commit | 040b7d37a460e5f023f7654b1b619368cbbc24ea (patch) | |
tree | 251a14cd362a6d98c1721e8f3f54fc386165e464 /app/services/remove_status_service.rb | |
parent | 94e98864e39c010635e839fea984f2b4893bef1a (diff) | |
parent | c3fac61f56b3ad63534961f3d3c426cdf8ac6213 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/services/remove_status_service.rb`: Conflict due to glitch-soc having extra code for a proper direct visibility timeline, in a part of the code upstream refactored. Restored glitch-soc's extra code in the refactored bit.
Diffstat (limited to 'app/services/remove_status_service.rb')
-rw-r--r-- | app/services/remove_status_service.rb | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index c31d89776..97afc3f61 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -3,6 +3,7 @@ class RemoveStatusService < BaseService include Redisable include Payloadable + include Lockable # Delete a status # @param [Status] status @@ -17,38 +18,34 @@ class RemoveStatusService < BaseService @account = status.account @options = options - RedisLock.acquire(lock_options) do |lock| - if lock.acquired? - @status.discard - - remove_from_self if @account.local? - remove_from_followers - remove_from_lists - - # There is no reason to send out Undo activities when the - # cause is that the original object has been removed, since - # original object being removed implicitly removes reblogs - # of it. The Delete activity of the original is forwarded - # separately. - remove_from_remote_reach if @account.local? && !@options[:original_removed] - - # Since reblogs don't mention anyone, don't get reblogged, - # favourited and don't contain their own media attachments - # or hashtags, this can be skipped - unless @status.reblog? - remove_from_mentions - remove_reblogs - remove_from_hashtags - remove_from_public - remove_from_media if @status.with_media? - remove_from_direct if status.direct_visibility? - remove_media - end - - @status.destroy! if permanently? - else - raise Mastodon::RaceConditionError + with_lock("distribute:#{@status.id}") do + @status.discard + + remove_from_self if @account.local? + remove_from_followers + remove_from_lists + + # There is no reason to send out Undo activities when the + # cause is that the original object has been removed, since + # original object being removed implicitly removes reblogs + # of it. The Delete activity of the original is forwarded + # separately. + remove_from_remote_reach if @account.local? && !@options[:original_removed] + + # Since reblogs don't mention anyone, don't get reblogged, + # favourited and don't contain their own media attachments + # or hashtags, this can be skipped + unless @status.reblog? + remove_from_mentions + remove_reblogs + remove_from_hashtags + remove_from_public + remove_from_media if @status.with_media? + remove_from_direct if status.direct_visibility? + remove_media end + + @status.destroy! if permanently? end end @@ -152,8 +149,4 @@ class RemoveStatusService < BaseService def permanently? @options[:immediate] || !(@options[:preserve] || @status.reported?) end - - def lock_options - { redis: redis, key: "distribute:#{@status.id}", autorelease: 5.minutes.seconds } - end end |