X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fmiddlewares%2Fvalidators%2Fserver.ts;h=d040e8a1f286b628268d3db9cb1c6331c2bea9d8;hb=HEAD;hp=2b34c4a76c7383b3b97d9e47f8270bf72f8a4137;hpb=76148b27f7501bac061992136852be4303370c8d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts index 2b34c4a76..d040e8a1f 100644 --- a/server/middlewares/validators/server.ts +++ b/server/middlewares/validators/server.ts @@ -1,20 +1,18 @@ -import * as express from 'express' -import { logger } from '../../helpers/logger' -import { areValidationErrors } from './utils' -import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' -import { ServerModel } from '../../models/server/server' +import express from 'express' import { body } from 'express-validator' +import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' +import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' -import { Redis } from '../../lib/redis' +import { logger } from '../../helpers/logger' import { CONFIG, isEmailEnabled } from '../../initializers/config' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { Redis } from '../../lib/redis' +import { ServerModel } from '../../models/server/server' +import { areValidationErrors } from './shared' const serverGetValidator = [ body('host').custom(isHostValid).withMessage('Should have a valid host'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking serverGetValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return const server = await ServerModel.loadByHost(req.body.host) @@ -33,15 +31,13 @@ const serverGetValidator = [ const contactAdministratorValidator = [ body('fromName') - .custom(isUserDisplayNameValid).withMessage('Should have a valid name'), + .custom(isUserDisplayNameValid), body('fromEmail') - .isEmail().withMessage('Should have a valid email'), + .isEmail(), body('body') - .custom(isValidContactBody).withMessage('Should have a valid body'), + .custom(isValidContactBody), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return if (CONFIG.CONTACT_FORM.ENABLED === false) {