aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/schedulers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-02 16:37:43 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commitdc13348070d808d0ba3feb56a435b835c2e7e791 (patch)
tree887202a33f1aa680fd8ece6ee465381f3931c64e /server/lib/schedulers
parent6e7e63b83f08ba68edc2bb9f72ff03d1802e45df (diff)
downloadPeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.gz
PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.zst
PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.zip
Add import finished and video published notifs
Diffstat (limited to 'server/lib/schedulers')
-rw-r--r--server/lib/schedulers/update-videos-scheduler.ts14
1 files changed, 12 insertions, 2 deletions
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'
6import { SCHEDULER_INTERVALS_MS, sequelizeTypescript } from '../../initializers' 6import { SCHEDULER_INTERVALS_MS, sequelizeTypescript } from '../../initializers'
7import { VideoPrivacy } from '../../../shared/models/videos' 7import { VideoPrivacy } from '../../../shared/models/videos'
8import { Notifier } from '../notifier' 8import { Notifier } from '../notifier'
9import { VideoModel } from '../../models/video/video'
9 10
10export class UpdateVideosScheduler extends AbstractScheduler { 11export class UpdateVideosScheduler extends AbstractScheduler {
11 12
@@ -24,8 +25,9 @@ export class UpdateVideosScheduler extends AbstractScheduler {
24 private async updateVideos () { 25 private async updateVideos () {
25 if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined 26 if (!await ScheduleVideoUpdateModel.areVideosToUpdate()) return undefined
26 27
27 return sequelizeTypescript.transaction(async t => { 28 const publishedVideos = await sequelizeTypescript.transaction(async t => {
28 const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t) 29 const schedules = await ScheduleVideoUpdateModel.listVideosToUpdate(t)
30 const publishedVideos: VideoModel[] = []
29 31
30 for (const schedule of schedules) { 32 for (const schedule of schedules) {
31 const video = schedule.Video 33 const video = schedule.Video
@@ -42,13 +44,21 @@ export class UpdateVideosScheduler extends AbstractScheduler {
42 await federateVideoIfNeeded(video, isNewVideo, t) 44 await federateVideoIfNeeded(video, isNewVideo, t)
43 45
44 if (oldPrivacy === VideoPrivacy.UNLISTED || oldPrivacy === VideoPrivacy.PRIVATE) { 46 if (oldPrivacy === VideoPrivacy.UNLISTED || oldPrivacy === VideoPrivacy.PRIVATE) {
45 Notifier.Instance.notifyOnNewVideo(video) 47 video.ScheduleVideoUpdate = schedule
48 publishedVideos.push(video)
46 } 49 }
47 } 50 }
48 51
49 await schedule.destroy({ transaction: t }) 52 await schedule.destroy({ transaction: t })
50 } 53 }
54
55 return publishedVideos
51 }) 56 })
57
58 for (const v of publishedVideos) {
59 Notifier.Instance.notifyOnNewVideo(v)
60 Notifier.Instance.notifyOnPendingVideoPublished(v)
61 }
52 } 62 }
53 63
54 static get Instance () { 64 static get Instance () {