0
0
Fork 0

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
This commit is contained in:
Eugen Rochko 2017-09-04 18:26:33 +02:00 committed by GitHub
parent 2293466edd
commit 9b50a9dd83
3 changed files with 40 additions and 8 deletions

View file

@ -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