From 5a9a56b78f6a62b3241f0dff1b8685001a3b3a1d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Jul 2022 10:32:56 +0200 Subject: Prevent error on highlighted thread --- server/middlewares/validators/shared/video-comments.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/middlewares/validators/shared/video-comments.ts index 386ae911f..8d1a16294 100644 --- a/server/middlewares/validators/shared/video-comments.ts +++ b/server/middlewares/validators/shared/video-comments.ts @@ -1,7 +1,7 @@ import express from 'express' import { VideoCommentModel } from '@server/models/video/video-comment' import { MVideoId } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' +import { HttpStatusCode, ServerErrorCode } from '@shared/models' async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { const id = parseInt(idArg + '', 10) @@ -16,7 +16,10 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide } if (videoComment.videoId !== video.id) { - res.fail({ message: 'Video comment is not associated to this video.' }) + res.fail({ + type: ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO, + message: 'Video comment is not associated to this video.' + }) return false } @@ -42,7 +45,10 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r } if (videoComment.videoId !== video.id) { - res.fail({ message: 'Video comment is not associated to this video.' }) + res.fail({ + type: ServerErrorCode.COMMENT_NOT_ASSOCIATED_TO_VIDEO, + message: 'Video comment is not associated to this video.' + }) return false } -- cgit v1.2.3