]>
Commit | Line | Data |
---|---|---|
1 | import { database as db } from '../../../initializers/database' | |
2 | import { logger } from '../../../helpers' | |
3 | import { addVideoToFriends } from '../../../lib' | |
4 | import { VideoInstance } from '../../../models' | |
5 | ||
6 | function process (data: { id: string }) { | |
7 | return db.Video.loadAndPopulateAuthorAndPodAndTags(data.id).then(video => { | |
8 | return video.transcodeVideofile().then(() => video) | |
9 | }) | |
10 | } | |
11 | ||
12 | function onError (err: Error, jobId: number) { | |
13 | logger.error('Error when transcoding video file in job %d.', jobId, err) | |
14 | return Promise.resolve() | |
15 | } | |
16 | ||
17 | function onSuccess (jobId: number, video: VideoInstance) { | |
18 | logger.info('Job %d is a success.', jobId) | |
19 | ||
20 | video.toAddRemoteJSON().then(remoteVideo => { | |
21 | // Now we'll add the video's meta data to our friends | |
22 | return addVideoToFriends(remoteVideo, null) | |
23 | }) | |
24 | } | |
25 | ||
26 | // --------------------------------------------------------------------------- | |
27 | ||
28 | export { | |
29 | process, | |
30 | onError, | |
31 | onSuccess | |
32 | } |