]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/videos/video-blacklist.ts
Increase video comments limit
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / videos / video-blacklist.ts
index db59427c74af544603e34214f99d5810ac4c91a1..4bd6a8333dd8a81486e1294cee31d65335547a17 100644 (file)
@@ -1,6 +1,6 @@
 import * as express from 'express'
-import { body, param, query } from 'express-validator/check'
-import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
+import { body, param, query } from 'express-validator'
+import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
 import { logger } from '../../../helpers/logger'
 import { areValidationErrors } from '../utils'
 import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
@@ -14,7 +14,7 @@ const videosBlacklistRemoveValidator = [
 
     if (areValidationErrors(req, res)) return
     if (!await doesVideoExist(req.params.videoId, res)) return
-    if (!await doesVideoBlacklistExist(res.locals.video.id, res)) return
+    if (!await doesVideoBlacklistExist(res.locals.videoAll.id, res)) return
 
     return next()
   }
@@ -24,7 +24,7 @@ const videosBlacklistAddValidator = [
   param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
   body('unfederate')
     .optional()
-    .toBoolean()
+    .customSanitizer(toBooleanOrNull)
     .custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),
   body('reason')
     .optional()
@@ -36,7 +36,7 @@ const videosBlacklistAddValidator = [
     if (areValidationErrors(req, res)) return
     if (!await doesVideoExist(req.params.videoId, res)) return
 
-    const video = res.locals.video
+    const video = res.locals.videoAll
     if (req.body.unfederate === true && video.remote === true) {
       return res
         .status(409)
@@ -59,7 +59,7 @@ const videosBlacklistUpdateValidator = [
 
     if (areValidationErrors(req, res)) return
     if (!await doesVideoExist(req.params.videoId, res)) return
-    if (!await doesVideoBlacklistExist(res.locals.video.id, res)) return
+    if (!await doesVideoBlacklistExist(res.locals.videoAll.id, res)) return
 
     return next()
   }
@@ -69,6 +69,10 @@ const videosBlacklistFiltersValidator = [
   query('type')
     .optional()
     .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'),
+  query('search')
+    .optional()
+    .not()
+    .isEmpty().withMessage('Should have a valid search'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
     logger.debug('Checking videos blacklist filters query', { parameters: req.query })