Fix reported statuses not being deleted after account deletion (#40650)

This commit is contained in:
Claire
2026-09-24 11:58:23 +00:00
committed by GitHub
parent 8474efc76f
commit cd4e10bb1d
2 changed files with 9 additions and 1 deletions

View File

@@ -163,6 +163,8 @@ class DeleteAccountService < BaseService
end
def purge_statuses!
@account.statuses.reorder(nil).where(id: reported_status_ids).in_batches.update_all('deleted_at = COALESCE(statuses.deleted_at, NOW())')
@account.statuses.reorder(nil).where.not(id: reported_status_ids).in_batches do |statuses|
BatchedRemoveStatusService.new.call(statuses, skip_side_effects: skip_side_effects?)
end

View File

@@ -7,6 +7,7 @@ RSpec.describe DeleteAccountService do
subject { described_class.new.call(account) }
let!(:status) { Fabricate(:status, account: account) }
let!(:reported_status) { Fabricate(:status, account: account) }
let!(:mention) { Fabricate(:mention, account: local_follower) }
let!(:status_with_mention) { Fabricate(:status, account: account, mentions: [mention]) }
let!(:media_attachment) { Fabricate(:media_attachment, account: account) }
@@ -28,8 +29,13 @@ RSpec.describe DeleteAccountService do
let!(:account_note) { Fabricate(:account_note, account: account) }
let!(:generated_annual_report) { Fabricate(:generated_annual_report, account: account) }
before do
Fabricate(:report, target_account: account, status_ids: [reported_status.id])
end
it 'deletes associated owned and target records and target notifications' do
subject
expect { subject }
.to change { reported_status.reload.deleted_at }.from(nil)
expect_deletion_of_associated_owned_records
expect_deletion_of_associated_target_records