- 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('privacy', videoData.privacy)
- options.video.set('channelId', videoData.channelId)
-
- if (options.updateViews === true) options.video.set('views', videoData.views)
- await options.video.save(sequelizeOptions)
-
- // Don't block on request
- generateThumbnailFromUrl(options.video, options.videoObject.icon)
- .catch(err => logger.warn('Cannot generate thumbnail of %s.', options.videoObject.id, { err }))
+ const to = overrideTo ? 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
+
+ await video.save(sequelizeOptions)
+
+ if (thumbnailModel) await video.addAndSaveThumbnail(thumbnailModel, t)
+
+ // FIXME: use icon URL instead
+ const previewUrl = buildRemoteBaseUrl(video, join(STATIC_PATHS.PREVIEWS, video.getPreview().filename))
+ const previewModel = createPlaceholderThumbnail(previewUrl, video, ThumbnailType.PREVIEW, PREVIEWS_SIZE)
+ await video.addAndSaveThumbnail(previewModel, t)