aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos/video-comments.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos/video-comments.ts')
-rw-r--r--server/middlewares/validators/videos/video-comments.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index a3c9febc4..226c9d436 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -14,6 +14,7 @@ import { AcceptResult, isLocalVideoCommentReplyAccepted, isLocalVideoThreadAccep
14import { Hooks } from '../../../lib/plugins/hooks' 14import { Hooks } from '../../../lib/plugins/hooks'
15import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video' 15import { MCommentOwnerVideoReply, MVideo, MVideoFullLight } from '../../../types/models/video'
16import { areValidationErrors } from '../utils' 16import { areValidationErrors } from '../utils'
17import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
17 18
18const listVideoCommentsValidator = [ 19const listVideoCommentsValidator = [
19 query('isLocal') 20 query('isLocal')
@@ -154,8 +155,8 @@ export {
154 155
155function isVideoCommentsEnabled (video: MVideo, res: express.Response) { 156function isVideoCommentsEnabled (video: MVideo, res: express.Response) {
156 if (video.commentsEnabled !== true) { 157 if (video.commentsEnabled !== true) {
157 res.status(409) 158 res.status(HttpStatusCode.CONFLICT_409)
158 .json({ error: 'Video comments are disabled for this video.' }) 159 .json({ error: 'Video comments are disabled for this video.' })
159 160
160 return false 161 return false
161 } 162 }
@@ -165,8 +166,8 @@ function isVideoCommentsEnabled (video: MVideo, res: express.Response) {
165 166
166function checkUserCanDeleteVideoComment (user: MUserAccountUrl, videoComment: MCommentOwnerVideoReply, res: express.Response) { 167function checkUserCanDeleteVideoComment (user: MUserAccountUrl, videoComment: MCommentOwnerVideoReply, res: express.Response) {
167 if (videoComment.isDeleted()) { 168 if (videoComment.isDeleted()) {
168 res.status(409) 169 res.status(HttpStatusCode.CONFLICT_409)
169 .json({ error: 'This comment is already deleted' }) 170 .json({ error: 'This comment is already deleted' })
170 171
171 return false 172 return false
172 } 173 }
@@ -178,7 +179,7 @@ function checkUserCanDeleteVideoComment (user: MUserAccountUrl, videoComment: MC
178 videoComment.accountId !== userAccount.id && // Not the comment owner 179 videoComment.accountId !== userAccount.id && // Not the comment owner
179 videoComment.Video.VideoChannel.accountId !== userAccount.id // Not the video owner 180 videoComment.Video.VideoChannel.accountId !== userAccount.id // Not the video owner
180 ) { 181 ) {
181 res.status(403) 182 res.status(HttpStatusCode.FORBIDDEN_403)
182 .json({ error: 'Cannot remove video comment of another user' }) 183 .json({ error: 'Cannot remove video comment of another user' })
183 184
184 return false 185 return false
@@ -214,7 +215,7 @@ async function isVideoCommentAccepted (req: express.Request, res: express.Respon
214 215
215 if (!acceptedResult || acceptedResult.accepted !== true) { 216 if (!acceptedResult || acceptedResult.accepted !== true) {
216 logger.info('Refused local comment.', { acceptedResult, acceptParameters }) 217 logger.info('Refused local comment.', { acceptedResult, acceptParameters })
217 res.status(403) 218 res.status(HttpStatusCode.FORBIDDEN_403)
218 .json({ error: acceptedResult.errorMessage || 'Refused local comment' }) 219 .json({ error: acceptedResult.errorMessage || 'Refused local comment' })
219 220
220 return false 221 return false