- const to = options.overrideTo ? options.overrideTo : options.videoObject.to
- const videoData = await videoActivityObjectToDBAttributes(options.channel, options.videoObject, to)
- options.video.set('name', videoData.name)
- options.video.set('uuid', videoData.uuid)
- options.video.set('url', videoData.url)
- options.video.set('category', videoData.category)
- options.video.set('licence', videoData.licence)
- options.video.set('language', videoData.language)
- options.video.set('description', videoData.description)
- options.video.set('support', videoData.support)
- options.video.set('nsfw', videoData.nsfw)
- options.video.set('commentsEnabled', videoData.commentsEnabled)
- options.video.set('downloadEnabled', videoData.downloadEnabled)
- options.video.set('waitTranscoding', videoData.waitTranscoding)
- options.video.set('state', videoData.state)
- options.video.set('duration', videoData.duration)
- options.video.set('createdAt', videoData.createdAt)
- options.video.set('publishedAt', videoData.publishedAt)
- options.video.set('originallyPublishedAt', videoData.originallyPublishedAt)
- options.video.set('privacy', videoData.privacy)
- options.video.set('channelId', videoData.channelId)
- options.video.set('views', videoData.views)
-
- await options.video.save(sequelizeOptions)
+ if (oldVideoChannel.Actor.serverId !== channel.Actor.serverId) {
+ throw new Error('New channel ' + channel.Actor.url + ' is not on the same server than new channel ' + oldVideoChannel.Actor.url)
+ }
+
+ const to = overrideTo || videoObject.to
+ const videoData = await videoActivityObjectToDBAttributes(channel, videoObject, to)
+ video.name = videoData.name
+ video.uuid = videoData.uuid
+ video.url = videoData.url
+ video.category = videoData.category
+ video.licence = videoData.licence
+ video.language = videoData.language
+ video.description = videoData.description
+ video.support = videoData.support
+ video.nsfw = videoData.nsfw
+ video.commentsEnabled = videoData.commentsEnabled
+ video.downloadEnabled = videoData.downloadEnabled
+ video.waitTranscoding = videoData.waitTranscoding
+ video.state = videoData.state
+ video.duration = videoData.duration
+ video.createdAt = videoData.createdAt
+ video.publishedAt = videoData.publishedAt
+ video.originallyPublishedAt = videoData.originallyPublishedAt
+ video.privacy = videoData.privacy
+ video.channelId = videoData.channelId
+ video.views = videoData.views
+ video.isLive = videoData.isLive
+
+ // Ensures we update the updated video attribute
+ video.changed('updatedAt', true)
+
+ const videoUpdated = await video.save(sequelizeOptions) as MVideoFullLight
+
+ if (thumbnailModel) await videoUpdated.addAndSaveThumbnail(thumbnailModel, t)
+
+ const previewIcon = getPreviewFromIcons(videoObject)
+ if (videoUpdated.getPreview() && previewIcon) {
+ const previewModel = createPlaceholderThumbnail({
+ fileUrl: previewIcon.url,
+ video,
+ type: ThumbnailType.PREVIEW,
+ size: previewIcon
+ })
+ await videoUpdated.addAndSaveThumbnail(previewModel, t)
+ }