Accept actors with url objects instead of string

pull/267/head
Chocobozzz 2018-01-24 16:15:27 +01:00
parent 529479f924
commit d765fafc3f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 8 additions and 1 deletions

View 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
}