]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/jobs/handlers/video-transcoder.ts
Remove any typing from server
[github/Chocobozzz/PeerTube.git] / server / lib / jobs / handlers / video-transcoder.ts
CommitLineData
e02643f3 1import { database as db } from '../../../initializers/database'
65fcc311
C
2import { logger } from '../../../helpers'
3import { addVideoToFriends } from '../../../lib'
69818c93 4import { VideoInstance } from '../../../models'
227d02fe 5
6fcd19ba
C
6function process (data: { id: string }) {
7 return db.Video.loadAndPopulateAuthorAndPodAndTags(data.id).then(video => {
8 return video.transcodeVideofile().then(() => video)
227d02fe
C
9 })
10}
11
6fcd19ba 12function onError (err: Error, jobId: number) {
ad0997ad 13 logger.error('Error when transcoding video file in job %d.', jobId, err)
6fcd19ba 14 return Promise.resolve()
227d02fe
C
15}
16
6fcd19ba 17function onSuccess (jobId: number, video: VideoInstance) {
227d02fe 18 logger.info('Job %d is a success.', jobId)
62326afb 19
6fcd19ba 20 video.toAddRemoteJSON().then(remoteVideo => {
62326afb 21 // Now we'll add the video's meta data to our friends
6fcd19ba 22 return addVideoToFriends(remoteVideo, null)
62326afb 23 })
227d02fe
C
24}
25
26// ---------------------------------------------------------------------------
27
65fcc311
C
28export {
29 process,
30 onError,
31 onSuccess
32}