X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fblocklist.ts;h=8ec6cb01d5d66f27bd1150caede84121bcac57c4;hb=564b9b55976873d87e669ace916f037b72fe2865;hp=3de614522da6e8dc4d4af8126a4155e8634de2f1;hpb=396f6f0140b0f76162e2378fd5a61e2f888673ed;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts index 3de614522..8ec6cb01d 100644 --- a/server/middlewares/validators/blocklist.ts +++ b/server/middlewares/validators/blocklist.ts @@ -1,11 +1,10 @@ import express from 'express' import { body, param, query } from 'express-validator' import { areValidActorHandles } from '@server/helpers/custom-validators/activitypub/actor' -import { toArray } from '@server/helpers/custom-validators/misc' import { getServerActor } from '@server/models/application/application' +import { arrayify } from '@shared/core-utils' import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' -import { logger } from '../../helpers/logger' import { WEBSERVER } from '../../initializers/constants' import { AccountBlocklistModel } from '../../models/account/account-blocklist' import { ServerModel } from '../../models/server/server' @@ -17,8 +16,6 @@ const blockAccountValidator = [ .exists(), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return @@ -42,8 +39,6 @@ const unblockAccountByAccountValidator = [ .exists(), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params }) - if (areValidationErrors(req, res)) return if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return @@ -60,8 +55,6 @@ const unblockAccountByServerValidator = [ .exists(), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params }) - if (areValidationErrors(req, res)) return if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return @@ -78,8 +71,6 @@ const blockServerValidator = [ .custom(isHostValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking serverGetValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return const host: string = req.body.host @@ -104,8 +95,6 @@ const unblockServerByAccountValidator = [ .custom(isHostValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params }) - if (areValidationErrors(req, res)) return const user = res.locals.oauth.token.User @@ -120,8 +109,6 @@ const unblockServerByServerValidator = [ .custom(isHostValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params }) - if (areValidationErrors(req, res)) return const serverActor = await getServerActor() @@ -134,17 +121,15 @@ const unblockServerByServerValidator = [ const blocklistStatusValidator = [ query('hosts') .optional() - .customSanitizer(toArray) + .customSanitizer(arrayify) .custom(isEachUniqueHostValid).withMessage('Should have a valid hosts array'), query('accounts') .optional() - .customSanitizer(toArray) + .customSanitizer(arrayify) .custom(areValidActorHandles).withMessage('Should have a valid accounts array'), (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking blocklistStatusValidator parameters', { query: req.query }) - if (areValidationErrors(req, res)) return return next()