Prefer to_json in self destruct scheduler (#38263)
This commit is contained in:
parent
d52d0e4ded
commit
e537292e2a
@ -55,13 +55,10 @@ class Scheduler::SelfDestructScheduler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def delete_account!(account)
|
def delete_account!(account)
|
||||||
payload = ActiveModelSerializers::SerializableResource.new(
|
json = ActivityPub::LinkedDataSignature
|
||||||
account,
|
.new(deletion_payload(account))
|
||||||
serializer: ActivityPub::DeleteActorSerializer,
|
.sign!(account)
|
||||||
adapter: ActivityPub::Adapter
|
.to_json
|
||||||
).as_json
|
|
||||||
|
|
||||||
json = JSON.generate(ActivityPub::LinkedDataSignature.new(payload).sign!(account))
|
|
||||||
|
|
||||||
ActivityPub::DeliveryWorker.push_bulk(inboxes, limit: 1_000) do |inbox_url|
|
ActivityPub::DeliveryWorker.push_bulk(inboxes, limit: 1_000) do |inbox_url|
|
||||||
[json, account.id, inbox_url]
|
[json, account.id, inbox_url]
|
||||||
@ -70,4 +67,12 @@ class Scheduler::SelfDestructScheduler
|
|||||||
# Do not call `Account#suspend!` because we don't want to issue a deletion request
|
# Do not call `Account#suspend!` because we don't want to issue a deletion request
|
||||||
account.update!(suspended_at: Time.now.utc, suspension_origin: :local)
|
account.update!(suspended_at: Time.now.utc, suspension_origin: :local)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deletion_payload(account)
|
||||||
|
ActiveModelSerializers::SerializableResource.new(
|
||||||
|
account,
|
||||||
|
serializer: ActivityPub::DeleteActorSerializer,
|
||||||
|
adapter: ActivityPub::Adapter
|
||||||
|
).as_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -39,6 +39,8 @@ RSpec.describe Scheduler::SelfDestructScheduler do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when sidekiq is operational' do
|
context 'when sidekiq is operational' do
|
||||||
|
let!(:other_account) { Fabricate :account, inbox_url: 'https://host.example/inbox', domain: 'host.example', protocol: :activitypub }
|
||||||
|
|
||||||
it 'suspends local non-suspended accounts' do
|
it 'suspends local non-suspended accounts' do
|
||||||
worker.perform
|
worker.perform
|
||||||
|
|
||||||
@ -51,6 +53,9 @@ RSpec.describe Scheduler::SelfDestructScheduler do
|
|||||||
|
|
||||||
worker.perform
|
worker.perform
|
||||||
|
|
||||||
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Delete', signature: be_present), account.id, other_account.inbox_url)
|
||||||
|
|
||||||
expect(account.reload.suspended_at).to be > 1.day.ago
|
expect(account.reload.suspended_at).to be > 1.day.ago
|
||||||
expect { deletion_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { deletion_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user