aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/crawl.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-31 15:14:40 +0200
committerChocobozzz <me@florianbigard.com>2019-05-31 15:17:04 +0200
commitee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a (patch)
treed18b7f8667ee41923c89744586c1b71b8691f4a2 /server/lib/activitypub/crawl.ts
parent57cfff78858b2360d9e038e2a504b761cb51da47 (diff)
downloadPeerTube-ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a.tar.gz
PeerTube-ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a.tar.zst
PeerTube-ee79b60e4e500a1dc7db8bcee560d9a4a1a5d17a.zip
More robust federation
In particular when fetching pleroma outbox
Diffstat (limited to 'server/lib/activitypub/crawl.ts')
-rw-r--r--server/lib/activitypub/crawl.ts19
1 files changed, 14 insertions, 5 deletions
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 <T> (uri: string, handler: HandlerFunction<T>
28 let i = 0 28 let i = 0
29 let nextLink = firstBody.first 29 let nextLink = firstBody.first
30 while (nextLink && i < limit) { 30 while (nextLink && i < limit) {
31 // Don't crawl ourselves 31 let body: any
32 const remoteHost = parse(nextLink).host
33 if (remoteHost === WEBSERVER.HOST) continue
34 32
35 options.uri = nextLink 33 if (typeof nextLink === 'string') {
34 // Don't crawl ourselves
35 const remoteHost = parse(nextLink).host
36 if (remoteHost === WEBSERVER.HOST) continue
37
38 options.uri = nextLink
39
40 const res = await doRequest<ActivityPubOrderedCollection<T>>(options)
41 body = res.body
42 } else {
43 // nextLink is already the object we want
44 body = nextLink
45 }
36 46
37 const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options)
38 nextLink = body.next 47 nextLink = body.next
39 i++ 48 i++
40 49