- await video.$set('Tags', tagInstances, { transaction })
- video.Tags = tagInstances
- } else {
- video.Tags = defaultValue || []
- }
-}
-
-async function publishAndFederateIfNeeded (video: MVideoUUID, wasLive = false) {
- const result = await sequelizeTypescript.transaction(async t => {
- // Maybe the video changed in database, refresh it
- const videoDatabase = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t)
- // Video does not exist anymore
- if (!videoDatabase) return undefined
-
- // We transcoded the video file in another format, now we can publish it
- const videoPublished = await videoDatabase.publishIfNeededAndSave(t)
-
- // If the video was not published, we consider it is a new one for other instances
- // Live videos are always federated, so it's not a new video
- await federateVideoIfNeeded(videoDatabase, !wasLive && videoPublished, t)
-
- return { videoDatabase, videoPublished }
- })
+ const internalTags = tags || []
+ const tagInstances = await TagModel.findOrCreateTags(internalTags, transaction)