1
0

block.rb 614 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. class Block < ApplicationRecord
  3. include Paginable
  4. include Streamable
  5. belongs_to :account
  6. belongs_to :target_account, class_name: 'Account'
  7. validates :account, :target_account, presence: true
  8. validates :account_id, uniqueness: { scope: :target_account_id }
  9. def verb
  10. destroyed? ? :unblock : :block
  11. end
  12. def target
  13. target_account
  14. end
  15. def object_type
  16. :person
  17. end
  18. def hidden?
  19. true
  20. end
  21. def title
  22. destroyed? ? "#{account.acct} is no longer blocking #{target_account.acct}" : "#{account.acct} blocked #{target_account.acct}"
  23. end
  24. end