aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/runners
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/runners')
-rw-r--r--server/middlewares/validators/runners/jobs.ts30
1 files changed, 21 insertions, 9 deletions
diff --git a/server/middlewares/validators/runners/jobs.ts b/server/middlewares/validators/runners/jobs.ts
index 384b209ba..62f9340a5 100644
--- a/server/middlewares/validators/runners/jobs.ts
+++ b/server/middlewares/validators/runners/jobs.ts
@@ -1,8 +1,9 @@
1import express from 'express' 1import express from 'express'
2import { body, param } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isUUIDValid } from '@server/helpers/custom-validators/misc' 3import { exists, isUUIDValid } from '@server/helpers/custom-validators/misc'
4import { 4import {
5 isRunnerJobAbortReasonValid, 5 isRunnerJobAbortReasonValid,
6 isRunnerJobArrayOfStateValid,
6 isRunnerJobErrorMessageValid, 7 isRunnerJobErrorMessageValid,
7 isRunnerJobProgressValid, 8 isRunnerJobProgressValid,
8 isRunnerJobSuccessPayloadValid, 9 isRunnerJobSuccessPayloadValid,
@@ -12,7 +13,9 @@ import {
12import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners' 13import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners'
13import { cleanUpReqFiles } from '@server/helpers/express-utils' 14import { cleanUpReqFiles } from '@server/helpers/express-utils'
14import { LiveManager } from '@server/lib/live' 15import { LiveManager } from '@server/lib/live'
16import { runnerJobCanBeCancelled } from '@server/lib/runners'
15import { RunnerJobModel } from '@server/models/runner/runner-job' 17import { RunnerJobModel } from '@server/models/runner/runner-job'
18import { arrayify } from '@shared/core-utils'
16import { 19import {
17 HttpStatusCode, 20 HttpStatusCode,
18 RunnerJobLiveRTMPHLSTranscodingPrivatePayload, 21 RunnerJobLiveRTMPHLSTranscodingPrivatePayload,
@@ -119,13 +122,7 @@ export const cancelRunnerJobValidator = [
119 (req: express.Request, res: express.Response, next: express.NextFunction) => { 122 (req: express.Request, res: express.Response, next: express.NextFunction) => {
120 const runnerJob = res.locals.runnerJob 123 const runnerJob = res.locals.runnerJob
121 124
122 const allowedStates = new Set<RunnerJobState>([ 125 if (runnerJobCanBeCancelled(runnerJob) !== true) {
123 RunnerJobState.PENDING,
124 RunnerJobState.PROCESSING,
125 RunnerJobState.WAITING_FOR_PARENT_JOB
126 ])
127
128 if (allowedStates.has(runnerJob.state) !== true) {
129 return res.fail({ 126 return res.fail({
130 status: HttpStatusCode.BAD_REQUEST_400, 127 status: HttpStatusCode.BAD_REQUEST_400,
131 message: 'Cannot cancel this job that is not in "pending", "processing" or "waiting for parent job" state', 128 message: 'Cannot cancel this job that is not in "pending", "processing" or "waiting for parent job" state',
@@ -137,6 +134,21 @@ export const cancelRunnerJobValidator = [
137 } 134 }
138] 135]
139 136
137export const listRunnerJobsValidator = [
138 query('search')
139 .optional()
140 .custom(exists),
141
142 query('stateOneOf')
143 .optional()
144 .customSanitizer(arrayify)
145 .custom(isRunnerJobArrayOfStateValid),
146
147 (req: express.Request, res: express.Response, next: express.NextFunction) => {
148 return next()
149 }
150]
151
140export const runnerJobGetValidator = [ 152export const runnerJobGetValidator = [
141 param('jobUUID').custom(isUUIDValid), 153 param('jobUUID').custom(isUUIDValid),
142 154