X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fredundancy.ts;h=d31b216f59a2d209b1408ee9b7eaee7b7ebb8df9;hb=2b621ac0ebe83693bba6354b3482a03ba58143e7;hp=da24f4c9b73d0033e24be16f14f579768efebbf7;hpb=10363c74c1d869f0e0c7bc4d0367b1f34d1bb6a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts index da24f4c9b..d31b216f5 100644 --- a/server/middlewares/validators/redundancy.ts +++ b/server/middlewares/validators/redundancy.ts @@ -1,16 +1,25 @@ -import * as express from 'express' +import express from 'express' import { body, param, query } from 'express-validator' import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' -import { exists, isBooleanValid, isIdOrUUIDValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' +import { + exists, + isBooleanValid, + isIdOrUUIDValid, + isIdValid, + toBooleanOrNull, + toCompleteUUID, + toIntOrNull +} from '../../helpers/custom-validators/misc' import { isHostValid } from '../../helpers/custom-validators/servers' import { logger } from '../../helpers/logger' import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' import { ServerModel } from '../../models/server/server' -import { areValidationErrors, doesVideoExist } from './shared' +import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from './shared' const videoFileRedundancyGetValidator = [ - param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), + isValidVideoIdParam('videoId'), + param('resolution') .customSanitizer(toIntOrNull) .custom(exists).withMessage('Should have a valid resolution'), @@ -56,9 +65,8 @@ const videoFileRedundancyGetValidator = [ ] const videoPlaylistRedundancyGetValidator = [ - param('videoId') - .custom(isIdOrUUIDValid) - .not().isEmpty().withMessage('Should have a valid video id'), + isValidVideoIdParam('videoId'), + param('streamingPlaylistType') .customSanitizer(toIntOrNull) .custom(exists).withMessage('Should have a valid streaming playlist type'), @@ -135,7 +143,8 @@ const listVideoRedundanciesValidator = [ const addVideoRedundancyValidator = [ body('videoId') - .custom(isIdValid) + .customSanitizer(toCompleteUUID) + .custom(isIdOrUUIDValid) .withMessage('Should have a valid video id'), async (req: express.Request, res: express.Response, next: express.NextFunction) => {