]>
Commit | Line | Data |
---|---|---|
e02643f3 | 1 | import { database as db } from '../../../initializers/database' |
40298b02 | 2 | import { updateVideoToFriends } from '../../friends' |
65fcc311 | 3 | import { logger } from '../../../helpers' |
69818c93 | 4 | import { VideoInstance } from '../../../models' |
40298b02 | 5 | import { VideoResolution } from '../../../../shared' |
227d02fe | 6 | |
40298b02 | 7 | function process (data: { videoUUID: string, resolution: VideoResolution }) { |
0a6658fd | 8 | return db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(data.videoUUID).then(video => { |
40298b02 | 9 | return video.transcodeOriginalVideofile(data.resolution).then(() => video) |
227d02fe C |
10 | }) |
11 | } | |
12 | ||
6fcd19ba | 13 | function onError (err: Error, jobId: number) { |
ad0997ad | 14 | logger.error('Error when transcoding video file in job %d.', jobId, err) |
6fcd19ba | 15 | return Promise.resolve() |
227d02fe C |
16 | } |
17 | ||
6fcd19ba | 18 | function onSuccess (jobId: number, video: VideoInstance) { |
227d02fe | 19 | logger.info('Job %d is a success.', jobId) |
62326afb | 20 | |
40298b02 C |
21 | const remoteVideo = video.toUpdateRemoteJSON() |
22 | ||
23 | // Now we'll add the video's meta data to our friends | |
24 | return updateVideoToFriends(remoteVideo, null) | |
227d02fe C |
25 | } |
26 | ||
27 | // --------------------------------------------------------------------------- | |
28 | ||
65fcc311 C |
29 | export { |
30 | process, | |
31 | onError, | |
32 | onSuccess | |
33 | } |