diff options
Diffstat (limited to 'server/middlewares/validators/runners/job-files.ts')
-rw-r--r-- | server/middlewares/validators/runners/job-files.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/server/middlewares/validators/runners/job-files.ts b/server/middlewares/validators/runners/job-files.ts new file mode 100644 index 000000000..56afa39aa --- /dev/null +++ b/server/middlewares/validators/runners/job-files.ts | |||
@@ -0,0 +1,27 @@ | |||
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 | ] | ||