diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-01 16:52:27 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-05-01 16:52:27 +0200 |
commit | 392ca0472a50ea930f46e22dccf5ce55b04ef588 (patch) | |
tree | 9f8c6b3dcb11a620a417205f9554e8d37e5f3e12 /app/models/email_domain_block.rb | |
parent | 252deefe3433d0cedafd973becd0d85b5182eb49 (diff) | |
parent | 33f3818d660c67194f94c7ff2bb180f4865e6748 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/javascript/packs/admin.js`: Conflicts due to glitch-soc's theming system. Upstream changes have been ported to `app/javascript/core/admin.js` - `app/models/trends/statuses.rb`: Minor conflict due to glitch-soc's option to allow CWed toots in trends. Ported upstream changes.
Diffstat (limited to 'app/models/email_domain_block.rb')
-rw-r--r-- | app/models/email_domain_block.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/app/models/email_domain_block.rb b/app/models/email_domain_block.rb index 36e7e62ab..0e1e663c1 100644 --- a/app/models/email_domain_block.rb +++ b/app/models/email_domain_block.rb @@ -3,16 +3,19 @@ # # Table name: email_domain_blocks # -# id :bigint(8) not null, primary key -# domain :string default(""), not null -# created_at :datetime not null -# updated_at :datetime not null -# parent_id :bigint(8) -# ips :inet is an Array -# last_refresh_at :datetime +# id :bigint(8) not null, primary key +# domain :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# parent_id :bigint(8) # class EmailDomainBlock < ApplicationRecord + self.ignored_columns = %w( + ips + last_refresh_at + ) + include DomainNormalizable belongs_to :parent, class_name: 'EmailDomainBlock', optional: true @@ -27,7 +30,7 @@ class EmailDomainBlock < ApplicationRecord @history ||= Trends::History.new('email_domain_blocks', id) end - def self.block?(domain_or_domains, ips: [], attempt_ip: nil) + def self.block?(domain_or_domains, attempt_ip: nil) domains = Array(domain_or_domains).map do |str| domain = begin if str.include?('@') @@ -48,10 +51,7 @@ class EmailDomainBlock < ApplicationRecord blocked = domains.any?(&:nil?) - scope = where(domain: domains) - scope = scope.or(where('ips && ARRAY[?]::inet[]', ips)) if ips.any? - - scope.find_each do |block| + where(domain: domains).find_each do |block| blocked = true block.history.add(attempt_ip) if attempt_ip.present? end |