mirror of https://github.com/tootsuite/mastodon
Forward ActivityPub deletes to followers of rebloggers (#4706)
parent
884b085f53
commit
0397c58b61
|
@ -8,7 +8,24 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
||||||
if status.nil?
|
if status.nil?
|
||||||
delete_later!(object_uri)
|
delete_later!(object_uri)
|
||||||
else
|
else
|
||||||
RemoveStatusService.new.call(status)
|
forward_for_reblogs(status)
|
||||||
|
delete_now!(status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def forward_for_reblogs(status)
|
||||||
|
ActivityPub::RawDistributionWorker.push_bulk(status.reblogs.includes(:account).references(:account).merge(Account.local).pluck(:account_id)) do |account|
|
||||||
|
[payload, account.id]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete_now!(status)
|
||||||
|
RemoveStatusService.new.call(status)
|
||||||
|
end
|
||||||
|
|
||||||
|
def payload
|
||||||
|
@payload ||= Oj.dump(@json)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ActivityPub::RawDistributionWorker
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options queue: 'push'
|
||||||
|
|
||||||
|
def perform(json, source_account_id)
|
||||||
|
@account = Account.find(source_account_id)
|
||||||
|
|
||||||
|
ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url|
|
||||||
|
[json, @account.id, inbox_url]
|
||||||
|
end
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def inboxes
|
||||||
|
@inboxes ||= @account.followers.inboxes
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue