The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

50 lines
1021 B

  1. # frozen_string_literal: true
  2. class REST::AnnouncementSerializer < ActiveModel::Serializer
  3. attributes :id, :content, :starts_at, :ends_at, :all_day,
  4. :published_at, :updated_at
  5. attribute :read, if: :current_user?
  6. has_many :mentions
  7. has_many :tags, serializer: REST::StatusSerializer::TagSerializer
  8. has_many :emojis, serializer: REST::CustomEmojiSerializer
  9. has_many :reactions, serializer: REST::ReactionSerializer
  10. def current_user?
  11. !current_user.nil?
  12. end
  13. def id
  14. object.id.to_s
  15. end
  16. def read
  17. object.announcement_mutes.where(account: current_user.account).exists?
  18. end
  19. def content
  20. Formatter.instance.linkify(object.text)
  21. end
  22. def reactions
  23. object.reactions(current_user&.account)
  24. end
  25. class AccountSerializer < ActiveModel::Serializer
  26. attributes :id, :username, :url, :acct
  27. def id
  28. object.id.to_s
  29. end
  30. def url
  31. ActivityPub::TagManager.instance.url_for(object)
  32. end
  33. def acct
  34. object.pretty_acct
  35. end
  36. end
  37. end