diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-24 16:15:27 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-25 18:41:17 +0100 |
commit | d765fafc3faf0db9818eb1a07161df1cb1bc0efa (patch) | |
tree | 578c58798467cf89c61ff3417eb0102810f3958c /server/lib/activitypub | |
parent | 529479f924b1849423fb087f9699f8ecb20610ca (diff) | |
download | PeerTube-d765fafc3faf0db9818eb1a07161df1cb1bc0efa.tar.gz PeerTube-d765fafc3faf0db9818eb1a07161df1cb1bc0efa.tar.zst PeerTube-d765fafc3faf0db9818eb1a07161df1cb1bc0efa.zip |
Accept actors with url objects instead of string
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/actor.ts | 9 |
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 | |||
362 | function 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 | } | ||