X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo.ts;h=d03ab04529bb749b91fbeee9da692fb90979961b;hb=40c52969f731b9102d4b33c4f5a80bfbbc651894;hp=81b7c41592c5c35e2b87fc6ca27b5f115556cc7e;hpb=d846d99c6c81028bb7bd3cb20abd433cbf396a22;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video.ts b/server/lib/video.ts index 81b7c4159..d03ab0452 100644 --- a/server/lib/video.ts +++ b/server/lib/video.ts @@ -81,8 +81,8 @@ async function setVideoTags (options: { } } -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 @@ -92,14 +92,15 @@ async function publishAndFederateIfNeeded (video: MVideoUUID) { 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) } }