1
0
Fork 0

Accept actors with url objects instead of string

This commit is contained in:
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

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
}