diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/activitypub/crawl.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index ba5b67bee..0ba59b47d 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../initializers/constants' | 1 | import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants' |
2 | import { doRequest } from '../../helpers/requests' | 2 | import { doRequest } from '../../helpers/requests' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import * as Bluebird from 'bluebird' | 4 | import * as Bluebird from 'bluebird' |
5 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' | 5 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' |
6 | import { checkUrlsSameHost } from '../../helpers/activitypub' | ||
7 | import { parse } from "url" | ||
6 | 8 | ||
7 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) | 9 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) |
8 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) | 10 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) |
@@ -27,6 +29,10 @@ async function crawlCollectionPage <T> (uri: string, handler: HandlerFunction<T> | |||
27 | let i = 0 | 29 | let i = 0 |
28 | let nextLink = firstBody.first | 30 | let nextLink = firstBody.first |
29 | while (nextLink && i < limit) { | 31 | while (nextLink && i < limit) { |
32 | // Don't crawl ourselves | ||
33 | const remoteHost = parse(nextLink).host | ||
34 | if (remoteHost === WEBSERVER.HOST) continue | ||
35 | |||
30 | options.uri = nextLink | 36 | options.uri = nextLink |
31 | 37 | ||
32 | const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options) | 38 | const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options) |