account_domain_block.rb 719 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: account_domain_blocks
  5. #
  6. # id :bigint(8) not null, primary key
  7. # domain :string
  8. # created_at :datetime not null
  9. # updated_at :datetime not null
  10. # account_id :bigint(8)
  11. #
  12. class AccountDomainBlock < ApplicationRecord
  13. include Paginable
  14. include DomainNormalizable
  15. belongs_to :account
  16. validates :domain, presence: true, uniqueness: { scope: :account_id }, domain: true
  17. after_commit :invalidate_domain_blocking_cache
  18. private
  19. def invalidate_domain_blocking_cache
  20. Rails.cache.delete("exclude_domains_for:#{account_id}")
  21. Rails.cache.delete(['exclude_domains', account_id, domain])
  22. end
  23. end