1
0

mute.rb 782 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: mutes
  5. #
  6. # id :bigint(8) not null, primary key
  7. # created_at :datetime not null
  8. # updated_at :datetime not null
  9. # account_id :bigint(8) not null
  10. # target_account_id :bigint(8) not null
  11. # hide_notifications :boolean default(TRUE), not null
  12. #
  13. class Mute < ApplicationRecord
  14. include Paginable
  15. include RelationshipCacheable
  16. belongs_to :account
  17. belongs_to :target_account, class_name: 'Account'
  18. validates :account_id, uniqueness: { scope: :target_account_id }
  19. after_commit :remove_blocking_cache
  20. private
  21. def remove_blocking_cache
  22. Rails.cache.delete("exclude_account_ids_for:#{account_id}")
  23. end
  24. end