aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/schedulers/update-videos-scheduler.ts21
1 files changed, 10 insertions, 11 deletions
diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts
index 3e75babcb..e61d4c2ac 100644
--- a/server/lib/schedulers/update-videos-scheduler.ts
+++ b/server/lib/schedulers/update-videos-scheduler.ts
@@ -7,6 +7,7 @@ import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
7import { Notifier } from '../notifier' 7import { Notifier } from '../notifier'
8import { sequelizeTypescript } from '../../initializers/database' 8import { sequelizeTypescript } from '../../initializers/database'
9import { MVideoFullLight } from '@server/types/models' 9import { MVideoFullLight } from '@server/types/models'
10import { VideoModel } from '@server/models/video/video'
10 11
11export class UpdateVideosScheduler extends AbstractScheduler { 12export class UpdateVideosScheduler extends AbstractScheduler {
12 13
@@ -25,12 +26,13 @@ export class UpdateVideosScheduler extends AbstractScheduler {
25 private async updateVideos () { 26 private async updateVideos () {
26 if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined 27 if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined
27 28
28 const publishedVideos = await sequelizeTypescript.transaction(async t => { 29 const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate()
29 const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t) 30 const publishedVideos: MVideoFullLight[] = []
30 const publishedVideos: MVideoFullLight[] = [] 31
32 for (const schedule of schedules) {
33 await sequelizeTypescript.transaction(async t => {
34 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(schedule.videoId, t)
31 35
32 for (const schedule of schedules) {
33 const video = schedule.Video
34 logger.info('Executing scheduled video update on %s.', video.uuid) 36 logger.info('Executing scheduled video update on %s.', video.uuid)
35 37
36 if (schedule.privacy) { 38 if (schedule.privacy) {
@@ -42,16 +44,13 @@ export class UpdateVideosScheduler extends AbstractScheduler {
42 await federateVideoIfNeeded(video, isNewVideo, t) 44 await federateVideoIfNeeded(video, isNewVideo, t)
43 45
44 if (wasConfidentialVideo) { 46 if (wasConfidentialVideo) {
45 const videoToPublish: MVideoFullLight = Object.assign(video, { ScheduleVideoUpdate: schedule, UserVideoHistories: [] }) 47 publishedVideos.push(video)
46 publishedVideos.push(videoToPublish)
47 } 48 }
48 } 49 }
49 50
50 await schedule.destroy({ transaction: t }) 51 await schedule.destroy({ transaction: t })
51 } 52 })
52 53 }
53 return publishedVideos
54 })
55 54
56 for (const v of publishedVideos) { 55 for (const v of publishedVideos) {
57 Notifier.Instance.notifyOnNewVideoIfNeeded(v) 56 Notifier.Instance.notifyOnNewVideoIfNeeded(v)