}
}
-async function publishAndFederateIfNeeded (video: MVideoUUID) {
- const { videoDatabase, videoPublished } = await sequelizeTypescript.transaction(async t => {
+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
const videoPublished = await videoDatabase.publishIfNeededAndSave(t)
// If the video was not published, we consider it is a new one for other instances
- await federateVideoIfNeeded(videoDatabase, videoPublished, t)
+ // Live videos are always federated, so it's not a new video
+ await federateVideoIfNeeded(videoDatabase, !wasLive && videoPublished, t)
return { videoDatabase, videoPublished }
})
- if (videoPublished) {
- Notifier.Instance.notifyOnNewVideoIfNeeded(videoDatabase)
- Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(videoDatabase)
+ if (result?.videoPublished) {
+ Notifier.Instance.notifyOnNewVideoIfNeeded(result.videoDatabase)
+ Notifier.Instance.notifyOnVideoPublishedAfterTranscoding(result.videoDatabase)
}
}