X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fcrawl.ts;h=336129b822013a0e3e01786069d6923005d1de27;hb=0c302acb3c358b4d4d8dee45aed1de1108ea37ea;hp=278abf7de0b3a9637b380521dd9f78158535686f;hpb=db4b15f21fbf4e33434e930ffc7fb768cdcf9d42;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index 278abf7de..336129b82 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts @@ -1,22 +1,20 @@ -import * as Bluebird from 'bluebird' +import Bluebird from 'bluebird' import { URL } from 'url' +import { retryTransactionWrapper } from '@server/helpers/database-utils' import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' import { logger } from '../../helpers/logger' import { doJSONRequest } from '../../helpers/requests' -import { ACTIVITY_PUB, REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants' +import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' type HandlerFunction = (items: T[]) => (Promise | Bluebird) -type CleanerFunction = (startedDate: Date) => (Promise | Bluebird) +type CleanerFunction = (startedDate: Date) => Promise async function crawlCollectionPage (argUrl: string, handler: HandlerFunction, cleaner?: CleanerFunction) { let url = argUrl logger.info('Crawling ActivityPub data on %s.', url) - const options = { - activityPub: true, - timeout: REQUEST_TIMEOUT - } + const options = { activityPub: true } const startDate = new Date() @@ -54,7 +52,7 @@ async function crawlCollectionPage (argUrl: string, handler: HandlerFunction } } - if (cleaner) await cleaner(startDate) + if (cleaner) await retryTransactionWrapper(cleaner, startDate) } export {