aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-24 16:15:27 +0100
committerChocobozzz <me@florianbigard.com>2018-01-25 18:41:17 +0100
commitd765fafc3faf0db9818eb1a07161df1cb1bc0efa (patch)
tree578c58798467cf89c61ff3417eb0102810f3958c
parent529479f924b1849423fb087f9699f8ecb20610ca (diff)
downloadPeerTube-d765fafc3faf0db9818eb1a07161df1cb1bc0efa.tar.gz
PeerTube-d765fafc3faf0db9818eb1a07161df1cb1bc0efa.tar.zst
PeerTube-d765fafc3faf0db9818eb1a07161df1cb1bc0efa.zip
Accept actors with url objects instead of string
-rw-r--r--server/lib/activitypub/actor.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 7494aadbb..c708b38ba 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -252,7 +252,7 @@ async function fetchRemoteActor (actorUrl: string): Promise<FetchRemoteActorResu
252 logger.info('Fetching remote actor %s.', actorUrl) 252 logger.info('Fetching remote actor %s.', actorUrl)
253 253
254 const requestResult = await doRequest(options) 254 const requestResult = await doRequest(options)
255 const actorJSON: ActivityPubActor = requestResult.body 255 const actorJSON: ActivityPubActor = normalizeActor(requestResult.body)
256 256
257 if (isActorObjectValid(actorJSON) === false) { 257 if (isActorObjectValid(actorJSON) === false) {
258 logger.debug('Remote actor JSON is not valid.', { actorJSON: actorJSON }) 258 logger.debug('Remote actor JSON is not valid.', { actorJSON: actorJSON })
@@ -358,3 +358,10 @@ async function refreshActorIfNeeded (actor: ActorModel) {
358 return actor 358 return actor
359 }) 359 })
360} 360}
361
362function normalizeActor (actor: any) {
363 if (actor && actor.url && typeof actor.url === 'string') return actor
364
365 actor.url = actor.url.href || actor.url.url
366 return actor
367}