1 # == Schema Information
5 # id :bigint(8) not null, primary key
15 # index_acls_on_address (address) USING gist
16 # index_acls_on_domain (domain)
17 # index_acls_on_mx (mx)
20 class Acl < ApplicationRecord
21 validates :k, :presence => true
23 def self.match(address, options = {})
24 acls = Acl.where("address >>= ?", address)
27 labels = options[:domain].split(".")
30 acls = acls.or(Acl.where(:domain => labels.join(".")))
35 acls = acls.or(Acl.where(:mx => options[:mx])) if options[:mx]
40 def self.no_account_creation(address, options = {})
41 match(address, options).exists?(:k => "no_account_creation")
44 def self.allow_account_creation(address, options = {})
45 acls = Acl.where("address >>= ?", address)
46 .and(Acl.where(:k => "allow_account_creation"))
47 acls = acls.and(Acl.where(:domain => options[:domain])) if options[:domain]
48 acls = acls.and(Acl.where(:mx => options[:mx])) if options[:mx]
53 def self.no_note_comment(address, domain = nil)
54 match(address, :domain => domain).exists?(:k => "no_note_comment")
57 def self.no_trace_download(address, domain = nil)
58 match(address, :domain => domain).exists?(:k => "no_trace_download")