1 # frozen_string_literal: true
3 # == Schema Information
7 # id :bigint not null, primary key
17 # index_acls_on_address (address) USING gist
18 # index_acls_on_domain (domain)
19 # index_acls_on_mx (mx)
22 class Acl < ApplicationRecord
23 validates :k, :presence => true
25 def self.match(address, options = {})
26 acls = Acl.where("address >>= ?", address)
29 labels = options[:domain].split(".")
32 acls = acls.or(Acl.where(:domain => labels.join(".")))
37 acls = acls.or(Acl.where(:mx => options[:mx])) if options[:mx]
42 def self.no_account_creation?(address, options = {})
43 match(address, options).exists?(:k => "no_account_creation")
46 def self.allow_account_creation?(address, options = {})
47 match(address, options).exists?(:k => "allow_account_creation")
50 def self.no_note_comment?(address, domain = nil)
51 match(address, :domain => domain).exists?(:k => "no_note_comment")
54 def self.no_trace_download?(address, domain = nil)
55 match(address, :domain => domain).exists?(:k => "no_trace_download")