diff options
Diffstat (limited to 'server/middlewares/validators/videos/video-comments.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-comments.ts | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts index 1afacfed8..aac25a787 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/middlewares/validators/videos/video-comments.ts | |||
@@ -155,9 +155,10 @@ export { | |||
155 | 155 | ||
156 | function isVideoCommentsEnabled (video: MVideo, res: express.Response) { | 156 | function isVideoCommentsEnabled (video: MVideo, res: express.Response) { |
157 | if (video.commentsEnabled !== true) { | 157 | if (video.commentsEnabled !== true) { |
158 | res.status(HttpStatusCode.CONFLICT_409) | 158 | res.fail({ |
159 | .json({ error: 'Video comments are disabled for this video.' }) | 159 | status: HttpStatusCode.CONFLICT_409, |
160 | 160 | message: 'Video comments are disabled for this video.' | |
161 | }) | ||
161 | return false | 162 | return false |
162 | } | 163 | } |
163 | 164 | ||
@@ -166,9 +167,10 @@ function isVideoCommentsEnabled (video: MVideo, res: express.Response) { | |||
166 | 167 | ||
167 | function checkUserCanDeleteVideoComment (user: MUserAccountUrl, videoComment: MCommentOwnerVideoReply, res: express.Response) { | 168 | function checkUserCanDeleteVideoComment (user: MUserAccountUrl, videoComment: MCommentOwnerVideoReply, res: express.Response) { |
168 | if (videoComment.isDeleted()) { | 169 | if (videoComment.isDeleted()) { |
169 | res.status(HttpStatusCode.CONFLICT_409) | 170 | res.fail({ |
170 | .json({ error: 'This comment is already deleted' }) | 171 | status: HttpStatusCode.CONFLICT_409, |
171 | 172 | message: 'This comment is already deleted' | |
173 | }) | ||
172 | return false | 174 | return false |
173 | } | 175 | } |
174 | 176 | ||
@@ -179,9 +181,10 @@ function checkUserCanDeleteVideoComment (user: MUserAccountUrl, videoComment: MC | |||
179 | videoComment.accountId !== userAccount.id && // Not the comment owner | 181 | videoComment.accountId !== userAccount.id && // Not the comment owner |
180 | videoComment.Video.VideoChannel.accountId !== userAccount.id // Not the video owner | 182 | videoComment.Video.VideoChannel.accountId !== userAccount.id // Not the video owner |
181 | ) { | 183 | ) { |
182 | res.status(HttpStatusCode.FORBIDDEN_403) | 184 | res.fail({ |
183 | .json({ error: 'Cannot remove video comment of another user' }) | 185 | status: HttpStatusCode.FORBIDDEN_403, |
184 | 186 | message: 'Cannot remove video comment of another user' | |
187 | }) | ||
185 | return false | 188 | return false |
186 | } | 189 | } |
187 | 190 | ||
@@ -215,9 +218,11 @@ async function isVideoCommentAccepted (req: express.Request, res: express.Respon | |||
215 | 218 | ||
216 | if (!acceptedResult || acceptedResult.accepted !== true) { | 219 | if (!acceptedResult || acceptedResult.accepted !== true) { |
217 | logger.info('Refused local comment.', { acceptedResult, acceptParameters }) | 220 | logger.info('Refused local comment.', { acceptedResult, acceptParameters }) |
218 | res.status(HttpStatusCode.FORBIDDEN_403) | ||
219 | .json({ error: acceptedResult?.errorMessage || 'Refused local comment' }) | ||
220 | 221 | ||
222 | res.fail({ | ||
223 | status: HttpStatusCode.FORBIDDEN_403, | ||
224 | message: acceptedResult?.errorMessage || 'Refused local comment' | ||
225 | }) | ||
221 | return false | 226 | return false |
222 | } | 227 | } |
223 | 228 | ||