]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Accept actors with url objects instead of string
authorChocobozzz <me@florianbigard.com>
Wed, 24 Jan 2018 15:15:27 +0000 (16:15 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 25 Jan 2018 17:41:17 +0000 (18:41 +0100)
server/lib/activitypub/actor.ts

index 7494aadbb84b7dca0c2e9ce7a92804ef43813f2b..c708b38ba1c74ef6fcc180f1df1b8f6f0cb85ada 100644 (file)
@@ -252,7 +252,7 @@ async function fetchRemoteActor (actorUrl: string): Promise<FetchRemoteActorResu
   logger.info('Fetching remote actor %s.', actorUrl)
 
   const requestResult = await doRequest(options)
-  const actorJSON: ActivityPubActor = requestResult.body
+  const actorJSON: ActivityPubActor = normalizeActor(requestResult.body)
 
   if (isActorObjectValid(actorJSON) === false) {
     logger.debug('Remote actor JSON is not valid.', { actorJSON: actorJSON })
@@ -358,3 +358,10 @@ async function refreshActorIfNeeded (actor: ActorModel) {
     return actor
   })
 }
+
+function normalizeActor (actor: any) {
+  if (actor && actor.url && typeof actor.url === 'string') return actor
+
+  actor.url = actor.url.href || actor.url.url
+  return actor
+}