aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos/videos.ts22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index a027c4840..96e0d6600 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -42,7 +42,12 @@ import { getServerActor } from '../../../helpers/utils'
42import { CONFIG } from '../../../initializers/config' 42import { CONFIG } from '../../../initializers/config'
43import { isLocalVideoAccepted } from '../../../lib/moderation' 43import { isLocalVideoAccepted } from '../../../lib/moderation'
44import { Hooks } from '../../../lib/plugins/hooks' 44import { Hooks } from '../../../lib/plugins/hooks'
45import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares' 45import {
46 checkUserCanManageVideo,
47 doesVideoChannelOfAccountExist,
48 doesVideoExist,
49 doesVideoFileOfVideoExist
50} from '../../../helpers/middlewares'
46import { MVideoFullLight } from '@server/typings/models' 51import { MVideoFullLight } from '@server/typings/models'
47import { getVideoWithAttributes } from '../../../helpers/video' 52import { getVideoWithAttributes } from '../../../helpers/video'
48 53
@@ -198,6 +203,20 @@ const videosCustomGetValidator = (
198const videosGetValidator = videosCustomGetValidator('all') 203const videosGetValidator = videosCustomGetValidator('all')
199const videosDownloadValidator = videosCustomGetValidator('all', true) 204const videosDownloadValidator = videosCustomGetValidator('all', true)
200 205
206const videoFileMetadataGetValidator = getCommonVideoEditAttributes().concat([
207 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
208 param('videoFileId').custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoFileId'),
209
210 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
211 logger.debug('Checking videoFileMetadataGet parameters', { parameters: req.params })
212
213 if (areValidationErrors(req, res)) return
214 if (!await doesVideoFileOfVideoExist(+req.params.videoFileId, req.params.id, res)) return
215
216 return next()
217 }
218])
219
201const videosRemoveValidator = [ 220const videosRemoveValidator = [
202 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), 221 param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
203 222
@@ -411,6 +430,7 @@ export {
411 videosAddValidator, 430 videosAddValidator,
412 videosUpdateValidator, 431 videosUpdateValidator,
413 videosGetValidator, 432 videosGetValidator,
433 videoFileMetadataGetValidator,
414 videosDownloadValidator, 434 videosDownloadValidator,
415 checkVideoFollowConstraints, 435 checkVideoFollowConstraints,
416 videosCustomGetValidator, 436 videosCustomGetValidator,