X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fvideos%2Fvideo-comments.ts;h=da2fafb10aaa32d6033244187b2fda2c5a72367a;hb=298b3fd31529c047e87d34d397af3b08833bd8d0;hp=1d81eb5d8f9af184254e5f6353f8b892b29f2ad4;hpb=d5d9b6d7bfb7e9426b6462f7fdf285df39eea820;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts index 1d81eb5d8..da2fafb10 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/middlewares/validators/videos/video-comments.ts @@ -50,7 +50,7 @@ const addVideoCommentThreadValidator = [ if (areValidationErrors(req, res)) return if (!await doesVideoExist(req.params.videoId, res)) return if (!isVideoCommentsEnabled(res.locals.videoAll, res)) return - if (!await isVideoCommentAccepted(req, res, res.locals.videoAll,false)) return + if (!await isVideoCommentAccepted(req, res, res.locals.videoAll, false)) return return next() } @@ -134,7 +134,7 @@ async function doesVideoCommentThreadExist (idArg: number | string, video: MVide if (videoComment.videoId !== video.id) { res.status(400) - .json({ error: 'Video comment is associated to this video.' }) + .json({ error: 'Video comment is not associated to this video.' }) .end() return false @@ -166,7 +166,7 @@ async function doesVideoCommentExist (idArg: number | string, video: MVideoId, r if (videoComment.videoId !== video.id) { res.status(400) - .json({ error: 'Video comment is associated to this video.' }) + .json({ error: 'Video comment is not associated to this video.' }) .end() return false @@ -189,6 +189,13 @@ function isVideoCommentsEnabled (video: MVideo, res: express.Response) { } function checkUserCanDeleteVideoComment (user: MUser, videoComment: MCommentOwner, res: express.Response) { + if (videoComment.isDeleted()) { + res.status(409) + .json({ error: 'This comment is already deleted' }) + .end() + return false + } + const account = videoComment.Account if (user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) === false && account.userId !== user.id) { res.status(403)