diff options
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r-- | server/middlewares/validators/videos/videos.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 96e0d6600..3a7869354 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -29,7 +29,7 @@ import { | |||
29 | } from '../../../helpers/custom-validators/videos' | 29 | } from '../../../helpers/custom-validators/videos' |
30 | import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' | 30 | import { getDurationFromVideoFile } from '../../../helpers/ffmpeg-utils' |
31 | import { logger } from '../../../helpers/logger' | 31 | import { logger } from '../../../helpers/logger' |
32 | import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' | 32 | import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants' |
33 | import { authenticatePromiseIfNeeded } from '../../oauth' | 33 | import { authenticatePromiseIfNeeded } from '../../oauth' |
34 | import { areValidationErrors } from '../utils' | 34 | import { areValidationErrors } from '../utils' |
35 | import { cleanUpReqFiles } from '../../../helpers/express-utils' | 35 | import { cleanUpReqFiles } from '../../../helpers/express-utils' |
@@ -301,6 +301,19 @@ const videosAcceptChangeOwnershipValidator = [ | |||
301 | } | 301 | } |
302 | ] | 302 | ] |
303 | 303 | ||
304 | const videosOverviewValidator = [ | ||
305 | query('page') | ||
306 | .optional() | ||
307 | .isInt({ min: 1, max: OVERVIEWS.VIDEOS.SAMPLES_COUNT }) | ||
308 | .withMessage('Should have a valid pagination'), | ||
309 | |||
310 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
311 | if (areValidationErrors(req, res)) return | ||
312 | |||
313 | return next() | ||
314 | } | ||
315 | ] | ||
316 | |||
304 | function getCommonVideoEditAttributes () { | 317 | function getCommonVideoEditAttributes () { |
305 | return [ | 318 | return [ |
306 | body('thumbnailfile') | 319 | body('thumbnailfile') |
@@ -442,7 +455,9 @@ export { | |||
442 | 455 | ||
443 | getCommonVideoEditAttributes, | 456 | getCommonVideoEditAttributes, |
444 | 457 | ||
445 | commonVideosFiltersValidator | 458 | commonVideosFiltersValidator, |
459 | |||
460 | videosOverviewValidator | ||
446 | } | 461 | } |
447 | 462 | ||
448 | // --------------------------------------------------------------------------- | 463 | // --------------------------------------------------------------------------- |