diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2021-07-02 12:03:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-02 12:03:15 +0200 |
commit | 38b34199507d81cac9f4ff18b5ce11f5e7ef9f23 (patch) | |
tree | f4d7a1f23c135996de5ba9e7aca59b7589a1703c /app/models/account.rb | |
parent | 92c8c30e177ff68c804707b72b123fede956d944 (diff) |
Fix not being able to suspend accounts that already have a canonical e-mail block (#16455)
Diffstat (limited to 'app/models/account.rb')
-rw-r--r-- | app/models/account.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 2c5455d8e..8be36bf5b 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -570,7 +570,11 @@ class Account < ApplicationRecord def create_canonical_email_block! return unless local? && user_email.present? - CanonicalEmailBlock.create(reference_account: self, email: user_email) + begin + CanonicalEmailBlock.create(reference_account: self, email: user_email) + rescue ActiveRecord::RecordNotUnique + # A canonical e-mail block may already exist for the same e-mail + end end def destroy_canonical_email_block! |