mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-27 07:28:05 -05:00
Fix reported statuses not being deleted after account deletion (#40650)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user