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.

38 lines
560 B

  1. class Favourite < ActiveRecord::Base
  2. belongs_to :account, inverse_of: :favourites
  3. belongs_to :status, inverse_of: :favourites
  4. has_one :stream_entry, as: :activity
  5. def verb
  6. :favorite
  7. end
  8. def title
  9. "#{self.account.acct} favourited a status by #{self.status.account.acct}"
  10. end
  11. def content
  12. title
  13. end
  14. def object_type
  15. target.object_type
  16. end
  17. def target
  18. self.status
  19. end
  20. def mentions
  21. []
  22. end
  23. def thread
  24. target
  25. end
  26. after_create do
  27. self.account.stream_entries.create!(activity: self)
  28. end
  29. end