-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<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
-type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>)
+type CleanerFunction = (startedDate: Date) => Promise<any>
async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, 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()
}
}
- if (cleaner) await cleaner(startDate)
+ if (cleaner) await retryTransactionWrapper(cleaner, startDate)
}
export {