- const { video, tags, transaction, defaultValue } = options
- // Set tags to the video
- if (tags) {
- const tagInstances = await TagModel.findOrCreateTags(tags, transaction)
-
- await video.$set('Tags', tagInstances, { transaction })
- video.Tags = tagInstances
- } else {
- video.Tags = defaultValue || []
+ const { video, tags, transaction } = options
+
+ const internalTags = tags || []
+ const tagInstances = await TagModel.findOrCreateTags(internalTags, transaction)
+
+ await video.$set('Tags', tagInstances, { transaction })
+ video.Tags = tagInstances
+}
+
+// ---------------------------------------------------------------------------
+
+async function buildMoveToObjectStorageJob (options: {
+ video: MVideoUUID
+ previousVideoState: VideoState
+ isNewVideo?: boolean // Default true
+}) {
+ const { video, previousVideoState, isNewVideo = true } = options
+
+ await VideoJobInfoModel.increaseOrCreate(video.uuid, 'pendingMove')
+
+ return {
+ type: 'move-to-object-storage' as 'move-to-object-storage',
+ payload: {
+ videoUUID: video.uuid,
+ isNewVideo,
+ previousVideoState
+ }