]>
Commit | Line | Data |
---|---|---|
e02643f3 | 1 | import { database as db } from '../../../initializers/database' |
65fcc311 C |
2 | import { logger } from '../../../helpers' |
3 | import { addVideoToFriends } from '../../../lib' | |
69818c93 | 4 | import { VideoInstance } from '../../../models' |
227d02fe | 5 | |
6fcd19ba C |
6 | function 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 | 12 | function 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 | 17 | function 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 |
28 | export { |
29 | process, | |
30 | onError, | |
31 | onSuccess | |
32 | } |