From 310b5219b38427f0c2c7ba57225afdd8f3064380 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Jul 2020 15:51:46 +0200 Subject: Add new abuses tests --- server/helpers/custom-validators/abuses.ts | 6 +++--- server/helpers/custom-validators/video-comments.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/abuses.ts b/server/helpers/custom-validators/abuses.ts index c21468caa..0ca06a252 100644 --- a/server/helpers/custom-validators/abuses.ts +++ b/server/helpers/custom-validators/abuses.ts @@ -3,10 +3,10 @@ import { AbuseFilter, abusePredefinedReasonsMap, AbusePredefinedReasonsString, A import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' import { exists, isArray } from './misc' -const VIDEO_ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES +const ABUSES_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.ABUSES function isAbuseReasonValid (value: string) { - return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.REASON) + return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.REASON) } function isAbusePredefinedReasonValid (value: AbusePredefinedReasonsString) { @@ -32,7 +32,7 @@ function isAbuseTimestampCoherent (endAt: number, { req }) { } function isAbuseModerationCommentValid (value: string) { - return exists(value) && validator.isLength(value, VIDEO_ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT) + return exists(value) && validator.isLength(value, ABUSES_CONSTRAINTS_FIELDS.MODERATION_COMMENT) } function isAbuseStateValid (value: string) { diff --git a/server/helpers/custom-validators/video-comments.ts b/server/helpers/custom-validators/video-comments.ts index a01680cbe..455ff4241 100644 --- a/server/helpers/custom-validators/video-comments.ts +++ b/server/helpers/custom-validators/video-comments.ts @@ -68,7 +68,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r async function doesCommentIdExist (idArg: number | string, res: express.Response) { const id = parseInt(idArg + '', 10) - const videoComment = await VideoCommentModel.loadById(id) + const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) if (!videoComment) { res.status(404) @@ -77,7 +77,7 @@ async function doesCommentIdExist (idArg: number | string, res: express.Response return false } - res.locals.videoComment = videoComment + res.locals.videoCommentFull = videoComment return true } -- cgit v1.2.3