diff options
Diffstat (limited to 'server/helpers/custom-validators/video-comments.ts')
-rw-r--r-- | server/helpers/custom-validators/video-comments.ts | 13 |
1 files changed, 7 insertions, 6 deletions
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' | |||
3 | import { VideoCommentModel } from '@server/models/video/video-comment' | 3 | import { VideoCommentModel } from '@server/models/video/video-comment' |
4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
5 | import { MVideoId } from '@server/types/models' | 5 | import { MVideoId } from '@server/types/models' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
6 | 7 | ||
7 | const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_COMMENTS | 8 | const VIDEO_COMMENTS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEO_COMMENTS |
8 | 9 | ||
@@ -15,7 +16,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide | |||
15 | const videoComment = await VideoCommentModel.loadById(id) | 16 | const videoComment = await VideoCommentModel.loadById(id) |
16 | 17 | ||
17 | if (!videoComment) { | 18 | if (!videoComment) { |
18 | res.status(404) | 19 | res.status(HttpStatusCode.NOT_FOUND_404) |
19 | .json({ error: 'Video comment thread not found' }) | 20 | .json({ error: 'Video comment thread not found' }) |
20 | .end() | 21 | .end() |
21 | 22 | ||
@@ -23,7 +24,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide | |||
23 | } | 24 | } |
24 | 25 | ||
25 | if (videoComment.videoId !== video.id) { | 26 | if (videoComment.videoId !== video.id) { |
26 | res.status(400) | 27 | res.status(HttpStatusCode.BAD_REQUEST_400) |
27 | .json({ error: 'Video comment is not associated to this video.' }) | 28 | .json({ error: 'Video comment is not associated to this video.' }) |
28 | .end() | 29 | .end() |
29 | 30 | ||
@@ -31,7 +32,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide | |||
31 | } | 32 | } |
32 | 33 | ||
33 | if (videoComment.inReplyToCommentId !== null) { | 34 | if (videoComment.inReplyToCommentId !== null) { |
34 | res.status(400) | 35 | res.status(HttpStatusCode.BAD_REQUEST_400) |
35 | .json({ error: 'Video comment is not a thread.' }) | 36 | .json({ error: 'Video comment is not a thread.' }) |
36 | .end() | 37 | .end() |
37 | 38 | ||
@@ -47,7 +48,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r | |||
47 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) | 48 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) |
48 | 49 | ||
49 | if (!videoComment) { | 50 | if (!videoComment) { |
50 | res.status(404) | 51 | res.status(HttpStatusCode.NOT_FOUND_404) |
51 | .json({ error: 'Video comment thread not found' }) | 52 | .json({ error: 'Video comment thread not found' }) |
52 | .end() | 53 | .end() |
53 | 54 | ||
@@ -55,7 +56,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r | |||
55 | } | 56 | } |
56 | 57 | ||
57 | if (videoComment.videoId !== video.id) { | 58 | if (videoComment.videoId !== video.id) { |
58 | res.status(400) | 59 | res.status(HttpStatusCode.BAD_REQUEST_400) |
59 | .json({ error: 'Video comment is not associated to this video.' }) | 60 | .json({ error: 'Video comment is not associated to this video.' }) |
60 | .end() | 61 | .end() |
61 | 62 | ||
@@ -71,7 +72,7 @@ async function doesCommentIdExist (idArg: number | string, res: express.Response | |||
71 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) | 72 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) |
72 | 73 | ||
73 | if (!videoComment) { | 74 | if (!videoComment) { |
74 | res.status(404) | 75 | res.status(HttpStatusCode.NOT_FOUND_404) |
75 | .json({ error: 'Video comment thread not found' }) | 76 | .json({ error: 'Video comment thread not found' }) |
76 | 77 | ||
77 | return false | 78 | return false |