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.
 
 
 
 

96 lines
1.5 KiB

  1. # frozen_string_literal: true
  2. class ActivityPub::ActorSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :id, :type, :following, :followers,
  5. :inbox, :outbox,
  6. :preferred_username, :name, :summary,
  7. :url, :manually_approves_followers
  8. has_one :public_key, serializer: ActivityPub::PublicKeySerializer
  9. class EndpointsSerializer < ActiveModel::Serializer
  10. include RoutingHelper
  11. attributes :shared_inbox
  12. def shared_inbox
  13. inbox_url
  14. end
  15. end
  16. has_one :endpoints, serializer: EndpointsSerializer
  17. has_one :icon, serializer: ActivityPub::ImageSerializer, if: :avatar_exists?
  18. has_one :image, serializer: ActivityPub::ImageSerializer, if: :header_exists?
  19. def id
  20. account_url(object)
  21. end
  22. def type
  23. 'Person'
  24. end
  25. def following
  26. account_following_index_url(object)
  27. end
  28. def followers
  29. account_followers_url(object)
  30. end
  31. def inbox
  32. account_inbox_url(object)
  33. end
  34. def outbox
  35. account_outbox_url(object)
  36. end
  37. def endpoints
  38. object
  39. end
  40. def preferred_username
  41. object.username
  42. end
  43. def name
  44. object.display_name
  45. end
  46. def summary
  47. Formatter.instance.simplified_format(object)
  48. end
  49. def icon
  50. object.avatar
  51. end
  52. def image
  53. object.header
  54. end
  55. def public_key
  56. object
  57. end
  58. def url
  59. short_account_url(object)
  60. end
  61. def avatar_exists?
  62. object.avatar.exists?
  63. end
  64. def header_exists?
  65. object.header.exists?
  66. end
  67. def manually_approves_followers
  68. object.locked
  69. end
  70. end