diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 22 |
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' | |||
42 | import { CONFIG } from '../../../initializers/config' | 42 | import { CONFIG } from '../../../initializers/config' |
43 | import { isLocalVideoAccepted } from '../../../lib/moderation' | 43 | import { isLocalVideoAccepted } from '../../../lib/moderation' |
44 | import { Hooks } from '../../../lib/plugins/hooks' | 44 | import { Hooks } from '../../../lib/plugins/hooks' |
45 | import { checkUserCanManageVideo, doesVideoChannelOfAccountExist, doesVideoExist } from '../../../helpers/middlewares' | 45 | import { |
46 | checkUserCanManageVideo, | ||
47 | doesVideoChannelOfAccountExist, | ||
48 | doesVideoExist, | ||
49 | doesVideoFileOfVideoExist | ||
50 | } from '../../../helpers/middlewares' | ||
46 | import { MVideoFullLight } from '@server/typings/models' | 51 | import { MVideoFullLight } from '@server/typings/models' |
47 | import { getVideoWithAttributes } from '../../../helpers/video' | 52 | import { getVideoWithAttributes } from '../../../helpers/video' |
48 | 53 | ||
@@ -198,6 +203,20 @@ const videosCustomGetValidator = ( | |||
198 | const videosGetValidator = videosCustomGetValidator('all') | 203 | const videosGetValidator = videosCustomGetValidator('all') |
199 | const videosDownloadValidator = videosCustomGetValidator('all', true) | 204 | const videosDownloadValidator = videosCustomGetValidator('all', true) |
200 | 205 | ||
206 | const 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 | |||
201 | const videosRemoveValidator = [ | 220 | const 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, |