diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-04 15:29:34 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-05-09 08:57:34 +0200 |
commit | 5e47f6ab984a7d00782e4c7030afffa1ba480add (patch) | |
tree | 1ce586b591a8d71acbc301eba29b9a5e6490439e /server/helpers/custom-validators | |
parent | 6a4905602636afd6650c9e6f4d0fcc2105d91100 (diff) | |
download | PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.gz PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.zst PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.zip |
Support studio transcoding in peertube runner
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r-- | server/helpers/custom-validators/misc.ts | 8 | ||||
-rw-r--r-- | server/helpers/custom-validators/runners/jobs.ts | 23 |
2 files changed, 28 insertions, 3 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index fa0f469f6..2c4cd1b9f 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -15,8 +15,12 @@ function isSafePath (p: string) { | |||
15 | }) | 15 | }) |
16 | } | 16 | } |
17 | 17 | ||
18 | function isSafeFilename (filename: string, extension: string) { | 18 | function isSafeFilename (filename: string, extension?: string) { |
19 | return typeof filename === 'string' && !!filename.match(new RegExp(`^[a-z0-9-]+\\.${extension}$`)) | 19 | const regex = extension |
20 | ? new RegExp(`^[a-z0-9-]+\\.${extension}$`) | ||
21 | : new RegExp(`^[a-z0-9-]+\\.[a-z0-9]{1,8}$`) | ||
22 | |||
23 | return typeof filename === 'string' && !!filename.match(regex) | ||
20 | } | 24 | } |
21 | 25 | ||
22 | function isSafePeerTubeFilenameWithoutExtension (filename: string) { | 26 | function isSafePeerTubeFilenameWithoutExtension (filename: string) { |
diff --git a/server/helpers/custom-validators/runners/jobs.ts b/server/helpers/custom-validators/runners/jobs.ts index 5f755d5bb..934bd37c9 100644 --- a/server/helpers/custom-validators/runners/jobs.ts +++ b/server/helpers/custom-validators/runners/jobs.ts | |||
@@ -6,6 +6,7 @@ import { | |||
6 | RunnerJobSuccessPayload, | 6 | RunnerJobSuccessPayload, |
7 | RunnerJobType, | 7 | RunnerJobType, |
8 | RunnerJobUpdatePayload, | 8 | RunnerJobUpdatePayload, |
9 | VideoEditionTranscodingSuccess, | ||
9 | VODAudioMergeTranscodingSuccess, | 10 | VODAudioMergeTranscodingSuccess, |
10 | VODHLSTranscodingSuccess, | 11 | VODHLSTranscodingSuccess, |
11 | VODWebVideoTranscodingSuccess | 12 | VODWebVideoTranscodingSuccess |
@@ -23,7 +24,8 @@ function isRunnerJobSuccessPayloadValid (value: RunnerJobSuccessPayload, type: R | |||
23 | return isRunnerJobVODWebVideoResultPayloadValid(value as VODWebVideoTranscodingSuccess, type, files) || | 24 | return isRunnerJobVODWebVideoResultPayloadValid(value as VODWebVideoTranscodingSuccess, type, files) || |
24 | isRunnerJobVODHLSResultPayloadValid(value as VODHLSTranscodingSuccess, type, files) || | 25 | isRunnerJobVODHLSResultPayloadValid(value as VODHLSTranscodingSuccess, type, files) || |
25 | isRunnerJobVODAudioMergeResultPayloadValid(value as VODHLSTranscodingSuccess, type, files) || | 26 | isRunnerJobVODAudioMergeResultPayloadValid(value as VODHLSTranscodingSuccess, type, files) || |
26 | isRunnerJobLiveRTMPHLSResultPayloadValid(value as LiveRTMPHLSTranscodingSuccess, type) | 27 | isRunnerJobLiveRTMPHLSResultPayloadValid(value as LiveRTMPHLSTranscodingSuccess, type) || |
28 | isRunnerJobVideoEditionResultPayloadValid(value as VideoEditionTranscodingSuccess, type, files) | ||
27 | } | 29 | } |
28 | 30 | ||
29 | // --------------------------------------------------------------------------- | 31 | // --------------------------------------------------------------------------- |
@@ -35,6 +37,7 @@ function isRunnerJobProgressValid (value: string) { | |||
35 | function isRunnerJobUpdatePayloadValid (value: RunnerJobUpdatePayload, type: RunnerJobType, files: UploadFilesForCheck) { | 37 | function isRunnerJobUpdatePayloadValid (value: RunnerJobUpdatePayload, type: RunnerJobType, files: UploadFilesForCheck) { |
36 | return isRunnerJobVODWebVideoUpdatePayloadValid(value, type, files) || | 38 | return isRunnerJobVODWebVideoUpdatePayloadValid(value, type, files) || |
37 | isRunnerJobVODHLSUpdatePayloadValid(value, type, files) || | 39 | isRunnerJobVODHLSUpdatePayloadValid(value, type, files) || |
40 | isRunnerJobVideoEditionUpdatePayloadValid(value, type, files) || | ||
38 | isRunnerJobVODAudioMergeUpdatePayloadValid(value, type, files) || | 41 | isRunnerJobVODAudioMergeUpdatePayloadValid(value, type, files) || |
39 | isRunnerJobLiveRTMPHLSUpdatePayloadValid(value, type, files) | 42 | isRunnerJobLiveRTMPHLSUpdatePayloadValid(value, type, files) |
40 | } | 43 | } |
@@ -102,6 +105,15 @@ function isRunnerJobLiveRTMPHLSResultPayloadValid ( | |||
102 | return type === 'live-rtmp-hls-transcoding' && (!value || (typeof value === 'object' && Object.keys(value).length === 0)) | 105 | return type === 'live-rtmp-hls-transcoding' && (!value || (typeof value === 'object' && Object.keys(value).length === 0)) |
103 | } | 106 | } |
104 | 107 | ||
108 | function isRunnerJobVideoEditionResultPayloadValid ( | ||
109 | _value: VideoEditionTranscodingSuccess, | ||
110 | type: RunnerJobType, | ||
111 | files: UploadFilesForCheck | ||
112 | ) { | ||
113 | return type === 'video-edition-transcoding' && | ||
114 | isFileValid({ files, field: 'payload[videoFile]', mimeTypeRegex: null, maxSize: null }) | ||
115 | } | ||
116 | |||
105 | // --------------------------------------------------------------------------- | 117 | // --------------------------------------------------------------------------- |
106 | 118 | ||
107 | function isRunnerJobVODWebVideoUpdatePayloadValid ( | 119 | function isRunnerJobVODWebVideoUpdatePayloadValid ( |
@@ -164,3 +176,12 @@ function isRunnerJobLiveRTMPHLSUpdatePayloadValid ( | |||
164 | ) | 176 | ) |
165 | ) | 177 | ) |
166 | } | 178 | } |
179 | |||
180 | function isRunnerJobVideoEditionUpdatePayloadValid ( | ||
181 | value: RunnerJobUpdatePayload, | ||
182 | type: RunnerJobType, | ||
183 | _files: UploadFilesForCheck | ||
184 | ) { | ||
185 | return type === 'video-edition-transcoding' && | ||
186 | (!value || (typeof value === 'object' && Object.keys(value).length === 0)) | ||
187 | } | ||