|
|
@ -3,6 +3,7 @@ |
|
|
|
class RemoveStatusService < BaseService |
|
|
|
include Redisable |
|
|
|
include Payloadable |
|
|
|
include Lockable |
|
|
|
|
|
|
|
# Delete a status |
|
|
|
# @param [Status] status |
|
|
@ -17,37 +18,33 @@ 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_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_media |
|
|
|
end |
|
|
|
|
|
|
|
@status.destroy! if permanently? |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
@ -144,8 +141,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 |