diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-22 13:44:22 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-22 13:54:46 +0200 |
commit | 17ecdf61ce1d374cc8ba17601b93c9bda08112b2 (patch) | |
tree | d3405d11636f661815c3ad09821944a5ae26ebfa /server/middlewares | |
parent | f3bc1b541619673f14db7de220b9c520a4f35ca8 (diff) | |
download | PeerTube-17ecdf61ce1d374cc8ba17601b93c9bda08112b2.tar.gz PeerTube-17ecdf61ce1d374cc8ba17601b93c9bda08112b2.tar.zst PeerTube-17ecdf61ce1d374cc8ba17601b93c9bda08112b2.zip |
Force stop remote live transcoding
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/runners/jobs.ts | 27 |
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' |
12 | import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners' | 12 | import { isRunnerTokenValid } from '@server/helpers/custom-validators/runners/runners' |
13 | import { cleanUpReqFiles } from '@server/helpers/express-utils' | 13 | import { cleanUpReqFiles } from '@server/helpers/express-utils' |
14 | import { LiveManager } from '@server/lib/live' | ||
14 | import { RunnerJobModel } from '@server/models/runner/runner-job' | 15 | import { RunnerJobModel } from '@server/models/runner/runner-job' |
15 | import { HttpStatusCode, RunnerJobState, RunnerJobSuccessBody, RunnerJobUpdateBody, ServerErrorCode } from '@shared/models' | 16 | import { |
17 | HttpStatusCode, | ||
18 | RunnerJobLiveRTMPHLSTranscodingPrivatePayload, | ||
19 | RunnerJobState, | ||
20 | RunnerJobSuccessBody, | ||
21 | RunnerJobUpdateBody, | ||
22 | ServerErrorCode | ||
23 | } from '@shared/models' | ||
16 | import { areValidationErrors } from '../shared' | 24 | import { areValidationErrors } from '../shared' |
17 | 25 | ||
18 | const tags = [ 'runner' ] | 26 | const 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 | ] |