import { ActorModel } from '../../models/activitypub/actor'
import { TagModel } from '../../models/video/tag'
import { VideoModel } from '../../models/video/video'
-import { VideoChannelModel } from '../../models/video/video-channel'
import { VideoFileModel } from '../../models/video/video-file'
import { getOrCreateActorAndServerAndModel } from './actor'
import { addVideoComments } from './video-comments'
import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type'
import { join } from 'path'
import { FilteredModelAttributes } from '../../typings/sequelize'
-import { Hooks } from '../plugins/hooks'
import { autoBlacklistVideoIfNeeded } from '../video-blacklist'
+import { ActorFollowScoreCache } from '../files-cache'
+import { AccountModelIdActor, VideoChannelModelId, VideoChannelModelIdActor } from '../../typings/models'
async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, transaction?: sequelize.Transaction) {
if (
}
if (syncParam.comments === true) {
- const handler = items => addVideoComments(items, video)
+ const handler = items => addVideoComments(items)
const cleaner = crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate)
await crawlCollectionPage<string>(fetchedVideo.comments, handler, cleaner)
async function updateVideoFromAP (options: {
video: VideoModel,
videoObject: VideoTorrentObject,
- account: AccountModel,
- channel: VideoChannelModel,
+ account: AccountModelIdActor,
+ channel: VideoChannelModelIdActor,
overrideTo?: string[]
}) {
const { video, videoObject, account, channel, overrideTo } = options
await retryTransactionWrapper(updateVideoFromAP, updateOptions)
await syncVideoExternalAttributes(video, videoObject, options.syncParam)
+ ActorFollowScoreCache.Instance.addGoodServerId(video.VideoChannel.Actor.serverId)
+
return video
} catch (err) {
logger.warn('Cannot refresh video %s.', options.video.url, { err })
+ ActorFollowScoreCache.Instance.addBadServerId(video.VideoChannel.Actor.serverId)
+
// Don't refresh in loop
await video.setAsRefreshed()
return video
const videoStreamingPlaylists = streamingPlaylistActivityUrlToDBAttributes(videoCreated, videoObject, videoFiles)
const playlistPromises = videoStreamingPlaylists.map(p => VideoStreamingPlaylistModel.create(p, { transaction: t }))
- await Promise.all(playlistPromises)
+ const streamingPlaylists = await Promise.all(playlistPromises)
// Process tags
const tags = videoObject.tag
const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
return VideoCaptionModel.insertOrReplaceLanguage(videoCreated.id, c.identifier, t)
})
- await Promise.all(videoCaptionsPromises)
+ const captions = await Promise.all(videoCaptionsPromises)
+
+ video.VideoFiles = videoFiles
+ video.VideoStreamingPlaylists = streamingPlaylists
+ video.Tags = tagInstances
+ video.VideoCaptions = captions
const autoBlacklisted = await autoBlacklistVideoIfNeeded({
video,
}
async function videoActivityObjectToDBAttributes (
- videoChannel: VideoChannelModel,
+ videoChannel: VideoChannelModelId,
videoObject: VideoTorrentObject,
to: string[] = []
) {