]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/schedulers/update-videos-scheduler.ts
Fix publishedAt after a scheduled update
[github/Chocobozzz/PeerTube.git] / server / lib / schedulers / update-videos-scheduler.ts
index a964648fd962a386001b306a679609f0ae055f9d..fd2edfd1702007665ce8cf03279db14194547c30 100644 (file)
@@ -1,6 +1,4 @@
-import { isTestInstance } from '../../helpers/core-utils'
 import { logger } from '../../helpers/logger'
-import { JobQueue } from '../job-queue'
 import { AbstractScheduler } from './abstract-scheduler'
 import { ScheduleVideoUpdateModel } from '../../models/video/schedule-video-update'
 import { retryTransactionWrapper } from '../../helpers/database-utils'
@@ -45,11 +43,12 @@ export class UpdateVideosScheduler extends AbstractScheduler {
 
         if (schedule.privacy) {
           const oldPrivacy = video.privacy
+          const isNewVideo = oldPrivacy === VideoPrivacy.PRIVATE
 
           video.privacy = schedule.privacy
-          await video.save({ transaction: t })
+          if (isNewVideo === true) video.publishedAt = new Date()
 
-          const isNewVideo = oldPrivacy === VideoPrivacy.PRIVATE
+          await video.save({ transaction: t })
           await federateVideoIfNeeded(video, isNewVideo, t)
         }