]>
Commit | Line | Data |
---|---|---|
0c9668f7 C |
1 | import express from 'express' |
2 | import { HttpStatusCode } from '@shared/models' | |
3 | import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' | |
4 | ||
5 | const tags = [ 'runner' ] | |
6 | ||
7 | export const runnerJobGetVideoTranscodingFileValidator = [ | |
8 | isValidVideoIdParam('videoId'), | |
9 | ||
10 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | |
11 | if (areValidationErrors(req, res)) return | |
12 | ||
13 | if (!await doesVideoExist(req.params.videoId, res, 'all')) return | |
14 | ||
15 | const runnerJob = res.locals.runnerJob | |
16 | ||
17 | if (runnerJob.privatePayload.videoUUID !== res.locals.videoAll.uuid) { | |
18 | return res.fail({ | |
19 | status: HttpStatusCode.FORBIDDEN_403, | |
20 | message: 'Job is not associated to this video', | |
21 | tags: [ ...tags, res.locals.videoAll.uuid ] | |
22 | }) | |
23 | } | |
24 | ||
25 | return next() | |
26 | } | |
27 | ] |