mute.rb 753 B

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