aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/runners/job-files.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/runners/job-files.ts')
-rw-r--r--server/middlewares/validators/runners/job-files.ts27
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 @@
1import express from 'express'
2import { HttpStatusCode } from '@shared/models'
3import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
4
5const tags = [ 'runner' ]
6
7export 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]