0
0
Fork 0

Fix UserCleanupScheduler crash when an unconfirmed account has a moderation note (#23318)

* Fix `UserCleanupScheduler` crash when an unconfirmed account has a moderation note

* Add tests
This commit is contained in:
Claire 2023-02-07 01:14:44 +01:00 committed by GitHub
parent 523a86618f
commit 9edefc779f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View file

@ -15,7 +15,7 @@ class Scheduler::UserCleanupScheduler
def clean_unconfirmed_accounts!
User.where('confirmed_at is NULL AND confirmation_sent_at <= ?', 2.days.ago).reorder(nil).find_in_batches do |batch|
# We have to do it separately because of missing database constraints
AccountModerationNote.where(account_id: batch.map(&:account_id)).delete_all
AccountModerationNote.where(target_account_id: batch.map(&:account_id)).delete_all
Account.where(id: batch.map(&:account_id)).delete_all
User.where(id: batch.map(&:id)).delete_all
end