aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/runners/jobs.ts27
1 files changed, 25 insertions, 2 deletions
diff --git a/server/middlewares/validators/runners/jobs.ts b/server/middlewares/validators/runners/jobs.ts
index de956a1ca..8174d4289 100644
--- a/server/middlewares/validators/runners/jobs.ts
+++ b/server/middlewares/validators/runners/jobs.ts
@@ -11,8 +11,16 @@ import {
11} from '@server/helpers/custom-validators/runners/jobs' 11} from '@server/helpers/custom-validators/runners/jobs'
12import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners' 12import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners'
13import { cleanUpReqFiles } from '@server/helpers/express-utils' 13import { cleanUpReqFiles } from '@server/helpers/express-utils'
14import { LiveManager } from '@server/lib/live'
14import { RunnerJobModel } from '@server/models/runner/runner-job' 15import { RunnerJobModel } from '@server/models/runner/runner-job'
15import { HttpStatusCode, RunnerJobState, RunnerJobSuccessBody, RunnerJobUpdateBody, ServerErrorCode } from '@shared/models' 16import {
17 HttpStatusCode,
18 RunnerJobLiveRTMPHLSTranscodingPrivatePayload,
19 RunnerJobState,
20 RunnerJobSuccessBody,
21 RunnerJobUpdateBody,
22 ServerErrorCode
23} from '@shared/models'
16import { areValidationErrors } from '../shared' 24import { areValidationErrors } from '../shared'
17 25
18const tags = [ 'runner' ] 26const tags = [ 'runner' ]
@@ -48,8 +56,9 @@ export const updateRunnerJobValidator = [
48 if (areValidationErrors(req, res, { tags })) return cleanUpReqFiles(req) 56 if (areValidationErrors(req, res, { tags })) return cleanUpReqFiles(req)
49 57
50 const body = req.body as RunnerJobUpdateBody 58 const body = req.body as RunnerJobUpdateBody
59 const job = res.locals.runnerJob
51 60
52 if (isRunnerJobUpdatePayloadValid(body.payload, res.locals.runnerJob.type, req.files) !== true) { 61 if (isRunnerJobUpdatePayloadValid(body.payload, job.type, req.files) !== true) {
53 cleanUpReqFiles(req) 62 cleanUpReqFiles(req)
54 63
55 return res.fail({ 64 return res.fail({
@@ -59,6 +68,20 @@ export const updateRunnerJobValidator = [
59 }) 68 })
60 } 69 }
61 70
71 if (res.locals.runnerJob.type === 'live-rtmp-hls-transcoding') {
72 const privatePayload = job.privatePayload as RunnerJobLiveRTMPHLSTranscodingPrivatePayload
73
74 if (!LiveManager.Instance.hasSession(privatePayload.sessionId)) {
75 cleanUpReqFiles(req)
76
77 return res.fail({
78 status: HttpStatusCode.BAD_REQUEST_400,
79 message: 'Session of this live ended',
80 tags
81 })
82 }
83 }
84
62 return next() 85 return next()
63 } 86 }
64] 87]