]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/search.ts
Reorganize plugin models
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / search.ts
index b4faa8894ab8620330f9187514f4bb5ef3244d1b..78213c70da16a02a163f63eb85489c541c5915bc 100644 (file)
@@ -28,7 +28,7 @@ const videosSearchValidator = [
   }
 ]
 
-const videoChannelsSearchValidator = [
+const videoChannelsListSearchValidator = [
   query('search').not().isEmpty().withMessage('Should have a valid search'),
   query('searchTarget').optional().custom(isSearchTargetValid).withMessage('Should have a valid search target'),
 
@@ -41,9 +41,22 @@ const videoChannelsSearchValidator = [
   }
 ]
 
+const videoChannelsOwnSearchValidator = [
+  query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
+
+  (req: express.Request, res: express.Response, next: express.NextFunction) => {
+    logger.debug('Checking video channels search query', { parameters: req.query })
+
+    if (areValidationErrors(req, res)) return
+
+    return next()
+  }
+]
+
 // ---------------------------------------------------------------------------
 
 export {
-  videoChannelsSearchValidator,
-  videosSearchValidator
+  videosSearchValidator,
+  videoChannelsListSearchValidator,
+  videoChannelsOwnSearchValidator
 }