]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/runners/job-files.ts
Implement remote runner jobs in server
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / runners / job-files.ts
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 ]