闭社主体 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.

59 lines
937 B

  1. # frozen_string_literal: true
  2. class ActivityPub::ActorSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :id, :type, :following, :followers,
  5. :inbox, :outbox, :preferred_username,
  6. :name, :summary, :icon, :image
  7. has_one :public_key, serializer: ActivityPub::PublicKeySerializer
  8. def id
  9. account_url(object)
  10. end
  11. def type
  12. 'Person'
  13. end
  14. def following
  15. account_following_index_url(object)
  16. end
  17. def followers
  18. account_followers_url(object)
  19. end
  20. def inbox
  21. nil
  22. end
  23. def outbox
  24. account_outbox_url(object)
  25. end
  26. def preferred_username
  27. object.username
  28. end
  29. def name
  30. object.display_name
  31. end
  32. def summary
  33. Formatter.instance.simplified_format(object)
  34. end
  35. def icon
  36. full_asset_url(object.avatar.url(:original))
  37. end
  38. def image
  39. full_asset_url(object.header.url(:original))
  40. end
  41. def public_key
  42. object
  43. end
  44. end