aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/video-live.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index cbc48fe93..ff92db910 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -11,6 +11,8 @@ import { CONFIG } from '../../../initializers/config'
11import { areValidationErrors } from '../utils' 11import { areValidationErrors } from '../utils'
12import { getCommonVideoEditAttributes } from './videos' 12import { getCommonVideoEditAttributes } from './videos'
13import { VideoModel } from '@server/models/video/video' 13import { VideoModel } from '@server/models/video/video'
14import { Hooks } from '@server/lib/plugins/hooks'
15import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
14 16
15const videoLiveGetValidator = [ 17const videoLiveGetValidator = [
16 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 18 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -97,6 +99,8 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
97 } 99 }
98 } 100 }
99 101
102 if (!await isLiveVideoAccepted(req, res)) return cleanUpReqFiles(req)
103
100 return next() 104 return next()
101 } 105 }
102]) 106])
@@ -137,3 +141,29 @@ export {
137 videoLiveUpdateValidator, 141 videoLiveUpdateValidator,
138 videoLiveGetValidator 142 videoLiveGetValidator
139} 143}
144
145// ---------------------------------------------------------------------------
146
147async function isLiveVideoAccepted (req: express.Request, res: express.Response) {
148 // Check we accept this video
149 const acceptParameters = {
150 liveVideoBody: req.body,
151 user: res.locals.oauth.token.User
152 }
153 const acceptedResult = await Hooks.wrapFun(
154 isLocalLiveVideoAccepted,
155 acceptParameters,
156 'filter:api.live-video.create.accept.result'
157 )
158
159 if (!acceptedResult || acceptedResult.accepted !== true) {
160 logger.info('Refused local live video.', { acceptedResult, acceptParameters })
161
162 res.status(403)
163 .json({ error: acceptedResult.errorMessage || 'Refused local live video' })
164
165 return false
166 }
167
168 return true
169}