Fix user email address being banned on self-deletion (#16503)
* Add tests * Fix user email address being banned on self-deletion Fixes #16498main
parent
31593d1426
commit
30ce6e395c
|
@ -42,7 +42,7 @@ class Settings::DeletesController < Settings::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_account!
|
def destroy_account!
|
||||||
current_account.suspend!(origin: :local)
|
current_account.suspend!(origin: :local, block_email: false)
|
||||||
AccountDeletionWorker.perform_async(current_user.account_id)
|
AccountDeletionWorker.perform_async(current_user.account_id)
|
||||||
sign_out
|
sign_out
|
||||||
end
|
end
|
||||||
|
|
|
@ -232,11 +232,11 @@ class Account < ApplicationRecord
|
||||||
suspended? && deletion_request.present?
|
suspended? && deletion_request.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def suspend!(date: Time.now.utc, origin: :local)
|
def suspend!(date: Time.now.utc, origin: :local, block_email: true)
|
||||||
transaction do
|
transaction do
|
||||||
create_deletion_request!
|
create_deletion_request!
|
||||||
update!(suspended_at: date, suspension_origin: origin)
|
update!(suspended_at: date, suspension_origin: origin)
|
||||||
create_canonical_email_block!
|
create_canonical_email_block! if block_email
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ describe Settings::DeletesController do
|
||||||
expect(user.account.reload).to be_suspended
|
expect(user.account.reload).to be_suspended
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not create an email block' do
|
||||||
|
expect(CanonicalEmailBlock.block?(user.email)).to be false
|
||||||
|
end
|
||||||
|
|
||||||
context 'when suspended' do
|
context 'when suspended' do
|
||||||
let(:user) { Fabricate(:user, account_attributes: { username: 'alice', suspended_at: Time.now.utc }) }
|
let(:user) { Fabricate(:user, account_attributes: { username: 'alice', suspended_at: Time.now.utc }) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue