X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fabuse.ts;h=70bae17758d48a8308529d862e5f9a22e7971036;hb=b302c80dc0d9ba8eabef9ef6576efe36afc57584;hp=e4aa1a8399c7a719e5564b8a1778a30e2ad0cf07;hpb=396f6f0140b0f76162e2378fd5a61e2f888673ed;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts index e4aa1a839..70bae1775 100644 --- a/server/middlewares/validators/abuse.ts +++ b/server/middlewares/validators/abuse.ts @@ -18,6 +18,7 @@ import { AbuseMessageModel } from '@server/models/abuse/abuse-message' import { AbuseCreate, UserRight } from '@shared/models' import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared' +import { forceNumber } from '@shared/core-utils' const abuseReportValidator = [ body('account.id') @@ -52,8 +53,6 @@ const abuseReportValidator = [ .custom(areAbusePredefinedReasonsValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking abuseReport parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return const body: AbuseCreate = req.body @@ -76,8 +75,6 @@ const abuseGetValidator = [ .custom(isIdValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking abuseGetValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return if (!await doesAbuseExist(req.params.id, res)) return @@ -97,8 +94,6 @@ const abuseUpdateValidator = [ .custom(isAbuseModerationCommentValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return if (!await doesAbuseExist(req.params.id, res)) return @@ -139,8 +134,6 @@ const abuseListForAdminsValidator = [ .custom(exists), (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return return next() @@ -161,8 +154,6 @@ const abuseListForUserValidator = [ .custom(isAbuseStateValid), (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return return next() @@ -174,8 +165,6 @@ const getAbuseValidator = [ .custom(isIdValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking getAbuseValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return if (!await doesAbuseExist(req.params.id, res)) return @@ -198,8 +187,6 @@ const getAbuseValidator = [ const checkAbuseValidForMessagesValidator = [ (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking checkAbuseValidForMessagesValidator parameters', { parameters: req.body }) - const abuse = res.locals.abuse if (abuse.ReporterAccount.isOwned() === false) { return res.fail({ message: 'This abuse was created by a user of your instance.' }) @@ -214,8 +201,6 @@ const addAbuseMessageValidator = [ .custom(isAbuseMessageValid), (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return return next() @@ -227,14 +212,12 @@ const deleteAbuseMessageValidator = [ .custom(isIdValid), async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body }) - if (areValidationErrors(req, res)) return const user = res.locals.oauth.token.user const abuse = res.locals.abuse - const messageId = parseInt(req.params.messageId + '', 10) + const messageId = forceNumber(req.params.messageId) const abuseMessage = await AbuseMessageModel.loadByIdAndAbuseId(messageId, abuse.id) if (!abuseMessage) {