diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-09-04 18:26:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-04 18:26:33 +0200 |
commit | 9b50a9dd835c3a08effc86a6ef3e29e3a16e3d27 (patch) | |
tree | b98173b3fe233f2d4d61c1f8caaac7f32b27f572 /app/serializers | |
parent | 2293466edd0972c2069628c55baec9b0cb861445 (diff) |
Fix some ActivityPub JSON bugs (#4796)
- Fix assumption that `url` is always a string. Handle it if it's an array of strings, array of objects, object, or string, both for accounts and for objects - `sharedInbox` is actually supposed to be under `endpoints`, handle both cases and adjust the serializer
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/activitypub/actor_serializer.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 25521eca9..a11178f5b 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -4,7 +4,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer include RoutingHelper attributes :id, :type, :following, :followers, - :inbox, :outbox, :shared_inbox, + :inbox, :outbox, :preferred_username, :name, :summary, :url, :manually_approves_followers @@ -24,6 +24,18 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer end end + class EndpointsSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :shared_inbox + + def shared_inbox + inbox_url + end + end + + has_one :endpoints, serializer: EndpointsSerializer + has_one :icon, serializer: ImageSerializer, if: :avatar_exists? has_one :image, serializer: ImageSerializer, if: :header_exists? @@ -51,8 +63,8 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer account_outbox_url(object) end - def shared_inbox - inbox_url + def endpoints + object end def preferred_username |