logo

mastofe

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

block.rb (786B)


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