- for (const uri of payload.uris) {
- await crawlCollectionPage<Activity>(uri, (items) => processActivities(items))
+ let video: MVideoFullLight
+ if (payload.videoId) video = await VideoModel.loadAndPopulateAccountAndServerAndTags(payload.videoId)
+
+ const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = {
+ 'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }),
+ 'video-shares': items => addVideoShares(items, video),
+ 'video-comments': items => addVideoComments(items),
+ 'account-playlists': items => createAccountPlaylists(items)
+ }
+
+ const cleanerType: { [ id in FetchType ]?: (crawlStartDate: Date) => Promise<any> } = {
+ 'video-shares': crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate),
+ 'video-comments': crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate)