mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Prefer to_json in self destruct scheduler (#38263)
This commit is contained in:
@@ -55,13 +55,10 @@ class Scheduler::SelfDestructScheduler
|
||||
end
|
||||
|
||||
def delete_account!(account)
|
||||
payload = ActiveModelSerializers::SerializableResource.new(
|
||||
account,
|
||||
serializer: ActivityPub::DeleteActorSerializer,
|
||||
adapter: ActivityPub::Adapter
|
||||
).as_json
|
||||
|
||||
json = JSON.generate(ActivityPub::LinkedDataSignature.new(payload).sign!(account))
|
||||
json = ActivityPub::LinkedDataSignature
|
||||
.new(deletion_payload(account))
|
||||
.sign!(account)
|
||||
.to_json
|
||||
|
||||
ActivityPub::DeliveryWorker.push_bulk(inboxes, limit: 1_000) do |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
|
||||
account.update!(suspended_at: Time.now.utc, suspension_origin: :local)
|
||||
end
|
||||
|
||||
def deletion_payload(account)
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
account,
|
||||
serializer: ActivityPub::DeleteActorSerializer,
|
||||
adapter: ActivityPub::Adapter
|
||||
).as_json
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,6 +39,8 @@ RSpec.describe Scheduler::SelfDestructScheduler do
|
||||
end
|
||||
|
||||
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
|
||||
worker.perform
|
||||
|
||||
@@ -51,6 +53,9 @@ RSpec.describe Scheduler::SelfDestructScheduler do
|
||||
|
||||
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 { deletion_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user