From 1b952dd4266b0da4887701e0ce0860faded96768 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Jun 2018 16:58:15 +0200 Subject: Reset published date on publish --- server/lib/job-queue/handlers/video-file.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts index a5c6bf300..fc40527c7 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts @@ -71,13 +71,18 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) { // Video does not exist anymore if (!videoDatabase) return undefined + let isNewVideo = false + // We transcoded the video file in another format, now we can publish it - const oldState = videoDatabase.state - videoDatabase.state = VideoState.PUBLISHED - videoDatabase = await videoDatabase.save({ transaction: t }) + if (videoDatabase.state !== VideoState.PUBLISHED) { + isNewVideo = true + + videoDatabase.state = VideoState.PUBLISHED + videoDatabase.publishedAt = new Date() + videoDatabase = await videoDatabase.save({ transaction: t }) + } // If the video was not published, we consider it is a new one for other instances - const isNewVideo = oldState !== VideoState.PUBLISHED await federateVideoIfNeeded(videoDatabase, isNewVideo, t) return undefined -- cgit v1.2.3