0
0
Fork 0

Extract by_domain_length scope in DomainNormalizable concern (#29517)

This commit is contained in:
Matt Jankowski 2024-03-12 09:09:11 -04:00 committed by GitHub
parent 5b60d4b696
commit d4ed7e466c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 3 deletions

View file

@ -56,7 +56,7 @@ class EmailDomainBlock < ApplicationRecord
end
def blocking?(allow_with_approval: false)
blocks = EmailDomainBlock.where(domain: domains_with_variants, allow_with_approval: allow_with_approval).order(Arel.sql('char_length(domain) desc'))
blocks = EmailDomainBlock.where(domain: domains_with_variants, allow_with_approval: allow_with_approval).by_domain_length
blocks.each { |block| block.history.add(@attempt_ip) } if @attempt_ip.present?
blocks.any?
end