X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=server%2Fmiddlewares%2Fvalidators%2Fvideos%2Fvideo-imports.ts;h=318dad10087b50e0fcaa25338aea8d2ed94bef21;hb=c8861d5dc0436ef4342ce517241e3591fa256a13;hp=48d20f904c8228d5462f8a502811f621c286e54c;hpb=54b3316099ed7d2dfcb6d708fdb686f1e125ce61;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts index 48d20f904..318dad100 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/middlewares/validators/videos/video-imports.ts @@ -1,18 +1,19 @@ import * as express from 'express' -import { body } from 'express-validator/check' -import { isIdValid } from '../../../helpers/custom-validators/misc' +import { body } from 'express-validator' +import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc' import { logger } from '../../../helpers/logger' import { areValidationErrors } from '../utils' -import { getCommonVideoAttributes } from './videos' +import { getCommonVideoEditAttributes } from './videos' import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' import { cleanUpReqFiles } from '../../../helpers/express-utils' -import { isVideoChannelOfAccountExist, isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' -import { CONFIG } from '../../../initializers/constants' -import { CONSTRAINTS_FIELDS } from '../../../initializers' +import { isVideoMagnetUriValid, isVideoNameValid } from '../../../helpers/custom-validators/videos' +import { CONFIG } from '../../../initializers/config' +import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' +import { doesVideoChannelOfAccountExist } from '../../../helpers/middlewares' -const videoImportAddValidator = getCommonVideoAttributes().concat([ +const videoImportAddValidator = getCommonVideoEditAttributes().concat([ body('channelId') - .toInt() + .customSanitizer(toIntOrNull) .custom(isIdValid).withMessage('Should have correct video channel id'), body('targetUrl') .optional() @@ -51,7 +52,7 @@ const videoImportAddValidator = getCommonVideoAttributes().concat([ .end() } - if (!await isVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) + if (!await doesVideoChannelOfAccountExist(req.body.channelId, user, res)) return cleanUpReqFiles(req) // Check we have at least 1 required param if (!req.body.targetUrl && !req.body.magnetUri && !torrentFile) {