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.

30 lines
659 B

  1. # frozen_string_literal: true
  2. class Follow < ApplicationRecord
  3. include Paginable
  4. include Streamable
  5. belongs_to :account
  6. belongs_to :target_account, class_name: 'Account'
  7. has_one :notification, as: :activity, dependent: :destroy
  8. validates :account, :target_account, presence: true
  9. validates :account_id, uniqueness: { scope: :target_account_id }
  10. def verb
  11. destroyed? ? :unfollow : :follow
  12. end
  13. def target
  14. target_account
  15. end
  16. def object_type
  17. :person
  18. end
  19. def title
  20. destroyed? ? "#{account.acct} is no longer following #{target_account.acct}" : "#{account.acct} started following #{target_account.acct}"
  21. end
  22. end