闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
614 B

  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