import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger'
import { Notifier } from '@server/lib/notifier'
import { PeerTubeSocket } from '@server/lib/peertube-socket'
+import { Hooks } from '@server/lib/plugins/hooks'
import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist'
import { VideoLiveModel } from '@server/models/video/video-live'
import { MActor, MChannelAccountLight, MChannelId, MVideoAccountLightBlacklistAllFiles, MVideoFullLight } from '@server/types/models'
import { VideoObject, VideoPrivacy } from '@shared/models'
-import { APVideoAbstractBuilder, getVideoAttributesFromObject } from './shared'
+import { APVideoAbstractBuilder, getVideoAttributesFromObject, updateVideoRates } from './shared'
export class APVideoUpdater extends APVideoAbstractBuilder {
private readonly wasPrivateVideo: boolean
private readonly wasUnlistedVideo: boolean
- private readonly videoFieldsSave: any
-
private readonly oldVideoChannel: MChannelAccountLight
protected lTags: LoggerTagsFn
this.oldVideoChannel = this.video.VideoChannel
- this.videoFieldsSave = this.video.toJSON()
-
this.lTags = loggerTagsFactory('ap', 'video', 'update', video.uuid, video.url)
}
transaction: undefined
})
+ await updateVideoRates(videoUpdated, this.videoObject)
+
// Notify our users?
if (this.wasPrivateVideo || this.wasUnlistedVideo) {
Notifier.Instance.notifyOnNewVideoIfNeeded(videoUpdated)
PeerTubeSocket.Instance.sendVideoLiveNewState(videoUpdated)
}
+ Hooks.runAction('action:activity-pub.remote-video.updated', { video: videoUpdated, videoAPObject: this.videoObject })
+
logger.info('Remote video with uuid %s updated', this.videoObject.uuid, this.lTags())
return videoUpdated
} catch (err) {
- this.catchUpdateError(err)
+ await this.catchUpdateError(err)
}
}
videoUpdated.VideoLive = null
}
- private catchUpdateError (err: Error) {
- if (this.video !== undefined && this.videoFieldsSave !== undefined) {
- resetSequelizeInstance(this.video, this.videoFieldsSave)
+ private async catchUpdateError (err: Error) {
+ if (this.video !== undefined) {
+ await resetSequelizeInstance(this.video)
}
// This is just a debug because we will retry the insert