diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-26 10:36:24 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | cef534ed53e4518fe0acf581bfe880788d42fc36 (patch) | |
tree | 115b51ea5136849a2336d44915c7780649f25dc2 /server/lib/job-queue/handlers | |
parent | 1de1d05f4c61fe059fa5e24e79c92582f0e7e4b3 (diff) | |
download | PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.gz PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.zst PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.zip |
Add user notification base code
Diffstat (limited to 'server/lib/job-queue/handlers')
-rw-r--r-- | server/lib/job-queue/handlers/video-file.ts | 5 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-import.ts | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts index 3dca2937f..959cc04fa 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts | |||
@@ -9,6 +9,7 @@ import { sequelizeTypescript } from '../../../initializers' | |||
9 | import * as Bluebird from 'bluebird' | 9 | import * as Bluebird from 'bluebird' |
10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' | 10 | import { computeResolutionsToTranscode } from '../../../helpers/ffmpeg-utils' |
11 | import { importVideoFile, transcodeOriginalVideofile, optimizeVideofile } from '../../video-transcoding' | 11 | import { importVideoFile, transcodeOriginalVideofile, optimizeVideofile } from '../../video-transcoding' |
12 | import { Notifier } from '../../notifier' | ||
12 | 13 | ||
13 | export type VideoFilePayload = { | 14 | export type VideoFilePayload = { |
14 | videoUUID: string | 15 | videoUUID: string |
@@ -86,6 +87,7 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) { | |||
86 | 87 | ||
87 | // If the video was not published, we consider it is a new one for other instances | 88 | // If the video was not published, we consider it is a new one for other instances |
88 | await federateVideoIfNeeded(videoDatabase, isNewVideo, t) | 89 | await federateVideoIfNeeded(videoDatabase, isNewVideo, t) |
90 | if (isNewVideo) Notifier.Instance.notifyOnNewVideo(video) | ||
89 | 91 | ||
90 | return undefined | 92 | return undefined |
91 | }) | 93 | }) |
@@ -134,7 +136,8 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: bo | |||
134 | logger.info('No transcoding jobs created for video %s (no resolutions).', videoDatabase.uuid, { privacy: videoDatabase.privacy }) | 136 | logger.info('No transcoding jobs created for video %s (no resolutions).', videoDatabase.uuid, { privacy: videoDatabase.privacy }) |
135 | } | 137 | } |
136 | 138 | ||
137 | return federateVideoIfNeeded(videoDatabase, isNewVideo, t) | 139 | await federateVideoIfNeeded(videoDatabase, isNewVideo, t) |
140 | if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase) | ||
138 | }) | 141 | }) |
139 | } | 142 | } |
140 | 143 | ||
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 63aacff98..82edb8d5c 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -15,6 +15,7 @@ import { VideoModel } from '../../../models/video/video' | |||
15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' | 15 | import { downloadWebTorrentVideo } from '../../../helpers/webtorrent' |
16 | import { getSecureTorrentName } from '../../../helpers/utils' | 16 | import { getSecureTorrentName } from '../../../helpers/utils' |
17 | import { remove, move, stat } from 'fs-extra' | 17 | import { remove, move, stat } from 'fs-extra' |
18 | import { Notifier } from '../../notifier' | ||
18 | 19 | ||
19 | type VideoImportYoutubeDLPayload = { | 20 | type VideoImportYoutubeDLPayload = { |
20 | type: 'youtube-dl' | 21 | type: 'youtube-dl' |
@@ -184,6 +185,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: Vide | |||
184 | // Now we can federate the video (reload from database, we need more attributes) | 185 | // Now we can federate the video (reload from database, we need more attributes) |
185 | const videoForFederation = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) | 186 | const videoForFederation = await VideoModel.loadAndPopulateAccountAndServerAndTags(video.uuid, t) |
186 | await federateVideoIfNeeded(videoForFederation, true, t) | 187 | await federateVideoIfNeeded(videoForFederation, true, t) |
188 | Notifier.Instance.notifyOnNewVideo(videoForFederation) | ||
187 | 189 | ||
188 | // Update video import object | 190 | // Update video import object |
189 | videoImport.state = VideoImportState.SUCCESS | 191 | videoImport.state = VideoImportState.SUCCESS |