logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

account_domain_block.rb (731B)


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