From ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 May 2019 15:14:40 +0200 Subject: More robust federation In particular when fetching pleroma outbox --- server/lib/activitypub/crawl.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'server/lib/activitypub/crawl.ts') diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index 686eef04d..9e469e3e6 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts @@ -28,13 +28,22 @@ async function crawlCollectionPage (uri: string, handler: HandlerFunction let i = 0 let nextLink = firstBody.first while (nextLink && i < limit) { - // Don't crawl ourselves - const remoteHost = parse(nextLink).host - if (remoteHost === WEBSERVER.HOST) continue + let body: any - options.uri = nextLink + if (typeof nextLink === 'string') { + // Don't crawl ourselves + const remoteHost = parse(nextLink).host + if (remoteHost === WEBSERVER.HOST) continue + + options.uri = nextLink + + const res = await doRequest>(options) + body = res.body + } else { + // nextLink is already the object we want + body = nextLink + } - const { body } = await doRequest>(options) nextLink = body.next i++ -- cgit v1.2.3