You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
782 B

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: canonical_email_blocks
  5. #
  6. # id :bigint(8) not null, primary key
  7. # canonical_email_hash :string default(""), not null
  8. # reference_account_id :bigint(8) not null
  9. # created_at :datetime not null
  10. # updated_at :datetime not null
  11. #
  12. class CanonicalEmailBlock < ApplicationRecord
  13. include EmailHelper
  14. belongs_to :reference_account, class_name: 'Account'
  15. validates :canonical_email_hash, presence: true, uniqueness: true
  16. def email=(email)
  17. self.canonical_email_hash = email_to_canonical_email_hash(email)
  18. end
  19. def self.block?(email)
  20. where(canonical_email_hash: email_to_canonical_email_hash(email)).exists?
  21. end
  22. end