]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/videos/video-comments.ts
Fix express validator
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / videos / video-comments.ts
index 9c1bfaeaaa307b68266ce073f4373943c587ea24..83a0c24b030ca49a05467fb79a1329a10b9be9df 100644 (file)
@@ -1,9 +1,8 @@
 import * as express from 'express'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
 import { UserRight } from '../../../../shared'
 import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
 import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
-import { doesVideoExist } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { UserModel } from '../../../models/account/user'
 import { VideoModel } from '../../../models/video/video'
@@ -11,6 +10,7 @@ import { VideoCommentModel } from '../../../models/video/video-comment'
 import { areValidationErrors } from '../utils'
 import { Hooks } from '../../../lib/plugins/hooks'
 import { isLocalVideoThreadAccepted, isLocalVideoCommentReplyAccepted, AcceptResult } from '../../../lib/moderation'
+import { doesVideoExist } from '../../../helpers/middlewares'
 
 const listVideoCommentThreadsValidator = [
   param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -210,13 +210,15 @@ async function isVideoCommentAccepted (req: express.Request, res: express.Respon
   if (isReply) {
     const acceptReplyParameters = Object.assign(acceptParameters, { parentComment: res.locals.videoComment })
 
-    acceptedResult = await Hooks.wrapObject(
-      isLocalVideoCommentReplyAccepted(acceptReplyParameters),
+    acceptedResult = await Hooks.wrapFun(
+      isLocalVideoCommentReplyAccepted,
+      acceptReplyParameters,
       'filter:api.video-comment-reply.create.accept.result'
     )
   } else {
-    acceptedResult = await Hooks.wrapObject(
-      isLocalVideoThreadAccepted(acceptParameters),
+    acceptedResult = await Hooks.wrapFun(
+      isLocalVideoThreadAccepted,
+      acceptParameters,
       'filter:api.video-thread.create.accept.result'
     )
   }