From dc13348070d808d0ba3feb56a435b835c2e7e791 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 2 Jan 2019 16:37:43 +0100 Subject: Add import finished and video published notifs --- server/lib/schedulers/update-videos-scheduler.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'server/lib/schedulers') diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts index b7fb029f1..2618a5857 100644 --- a/server/lib/schedulers/update-videos-scheduler.ts +++ b/server/lib/schedulers/update-videos-scheduler.ts @@ -6,6 +6,7 @@ import { federateVideoIfNeeded } from '../activitypub' import { SCHEDULER_INTERVALS_MS, sequelizeTypescript } from '../../initializers' import { VideoPrivacy } from '../../../shared/models/videos' import { Notifier } from '../notifier' +import { VideoModel } from '../../models/video/video' export class UpdateVideosScheduler extends AbstractScheduler { @@ -24,8 +25,9 @@ export class UpdateVideosScheduler extends AbstractScheduler { private async updateVideos () { if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined - return sequelizeTypescript.transaction(async t => { + const publishedVideos = await sequelizeTypescript.transaction(async t => { const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t) + const publishedVideos: VideoModel[] = [] for (const schedule of schedules) { const video = schedule.Video @@ -42,13 +44,21 @@ export class UpdateVideosScheduler extends AbstractScheduler { await federateVideoIfNeeded(video, isNewVideo, t) if (oldPrivacy === VideoPrivacy.UNLISTED || oldPrivacy === VideoPrivacy.PRIVATE) { - Notifier.Instance.notifyOnNewVideo(video) + video.ScheduleVideoUpdate = schedule + publishedVideos.push(video) } } await schedule.destroy({ transaction: t }) } + + return publishedVideos }) + + for (const v of publishedVideos) { + Notifier.Instance.notifyOnNewVideo(v) + Notifier.Instance.notifyOnPendingVideoPublished(v) + } } static get Instance () { -- cgit v1.2.3