X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideo-comments.ts;h=8d3ce580e744d3382d81bd0d370d36c29532e765;hb=f2eb23cd87cf32b8fe545178143b5f49e06a58da;hp=455ff424110442bfd166554ba41d4ef5cba8b278;hpb=ec903c010ecc54ec2acad0bf2cf10e7fbf6a0fa2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/video-comments.ts b/server/helpers/custom-validators/video-comments.ts index 455ff4241..8d3ce580e 100644 --- a/server/helpers/custom-validators/video-comments.ts +++ b/server/helpers/custom-validators/video-comments.ts @@ -3,6 +3,7 @@ import validator from 'validator' import { VideoCommentModel } from '@server/models/video/video-comment' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' import { MVideoId } from '@server/types/models' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_COMMENTS @@ -15,7 +16,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide const videoComment = await VideoCommentModel.loadById(id) if (!videoComment) { - res.status(404) + res.status(HttpStatusCode.NOT_FOUND_404) .json({ error: 'Video comment thread not found' }) .end() @@ -23,7 +24,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide } if (videoComment.videoId !== video.id) { - res.status(400) + res.status(HttpStatusCode.BAD_REQUEST_400) .json({ error: 'Video comment is not associated to this video.' }) .end() @@ -31,7 +32,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide } if (videoComment.inReplyToCommentId !== null) { - res.status(400) + res.status(HttpStatusCode.BAD_REQUEST_400) .json({ error: 'Video comment is not a thread.' }) .end() @@ -47,7 +48,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) if (!videoComment) { - res.status(404) + res.status(HttpStatusCode.NOT_FOUND_404) .json({ error: 'Video comment thread not found' }) .end() @@ -55,7 +56,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r } if (videoComment.videoId !== video.id) { - res.status(400) + res.status(HttpStatusCode.BAD_REQUEST_400) .json({ error: 'Video comment is not associated to this video.' }) .end() @@ -71,7 +72,7 @@ async function doesCommentIdExist (idArg: number | string, res: express.Response const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) if (!videoComment) { - res.status(404) + res.status(HttpStatusCode.NOT_FOUND_404) .json({ error: 'Video comment thread not found' }) return false