]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/videos/video-abuses.ts
Move to eslint
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / videos / video-abuses.ts
index be26ca16a6339aa948c6dbb3300ec178a350b0b9..a4aef4024a8d9e470cbe1c3f0163df9bd1e0d699 100644 (file)
@@ -1,16 +1,14 @@
 import * as express from 'express'
-import 'express-validator'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
 import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
-import { isVideoExist } from '../../../helpers/custom-validators/videos'
 import { logger } from '../../../helpers/logger'
 import { areValidationErrors } from '../utils'
 import {
-  isVideoAbuseExist,
   isVideoAbuseModerationCommentValid,
   isVideoAbuseReasonValid,
   isVideoAbuseStateValid
 } from '../../../helpers/custom-validators/video-abuses'
+import { doesVideoAbuseExist, doesVideoExist } from '../../../helpers/middlewares'
 
 const videoAbuseReportValidator = [
   param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -20,7 +18,7 @@ const videoAbuseReportValidator = [
     logger.debug('Checking videoAbuseReport parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
 
     return next()
   }
@@ -34,8 +32,8 @@ const videoAbuseGetValidator = [
     logger.debug('Checking videoAbuseGetValidator parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoAbuseExist(req.params.id, res.locals.video.id, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoAbuseExist(req.params.id, res.locals.videoAll.id, res)) return
 
     return next()
   }
@@ -55,8 +53,8 @@ const videoAbuseUpdateValidator = [
     logger.debug('Checking videoAbuseUpdateValidator parameters', { parameters: req.body })
 
     if (areValidationErrors(req, res)) return
-    if (!await isVideoExist(req.params.videoId, res)) return
-    if (!await isVideoAbuseExist(req.params.id, res.locals.video.id, res)) return
+    if (!await doesVideoExist(req.params.videoId, res)) return
+    if (!await doesVideoAbuseExist(req.params.id, res.locals.videoAll.id, res)) return
 
     return next()
   }