mute.rb 1016 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. # expires_at :datetime
  13. #
  14. class Mute < ApplicationRecord
  15. include Paginable
  16. include RelationshipCacheable
  17. include Expireable
  18. belongs_to :account
  19. belongs_to :target_account, class_name: 'Account'
  20. validates :account_id, uniqueness: { scope: :target_account_id }
  21. after_commit :invalidate_blocking_cache
  22. after_commit :invalidate_follow_recommendations_cache
  23. private
  24. def invalidate_blocking_cache
  25. Rails.cache.delete("exclude_account_ids_for:#{account_id}")
  26. end
  27. def invalidate_follow_recommendations_cache
  28. Rails.cache.delete("follow_recommendations/#{account_id}")
  29. end
  30. end