]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/user-history.ts
Use saveInTransactionWithRetries helper
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / user-history.ts
index f9be26627848806e8046bb30c1679cee76a4832f..f2dae313437ad42c8a8835b25bdb21b52bd6504b 100644 (file)
@@ -1,31 +1,37 @@
 import express from 'express'
-import { body, query } from 'express-validator'
-import { exists, isDateValid } from '../../helpers/custom-validators/misc'
-import { logger } from '../../helpers/logger'
+import { body, param, query } from 'express-validator'
+import { exists, isDateValid, isIdValid } from '../../helpers/custom-validators/misc'
 import { areValidationErrors } from './shared'
 
 const userHistoryListValidator = [
   query('search')
     .optional()
-    .custom(exists).withMessage('Should have a valid search'),
+    .custom(exists),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })
-
     if (areValidationErrors(req, res)) return
 
     return next()
   }
 ]
 
-const userHistoryRemoveValidator = [
+const userHistoryRemoveAllValidator = [
   body('beforeDate')
     .optional()
     .custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
-    logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body })
+    if (areValidationErrors(req, res)) return
+
+    return next()
+  }
+]
 
+const userHistoryRemoveElementValidator = [
+  param('videoId')
+    .custom(isIdValid),
+
+  (req: express.Request, res: express.Response, next: express.NextFunction) => {
     if (areValidationErrors(req, res)) return
 
     return next()
@@ -36,5 +42,6 @@ const userHistoryRemoveValidator = [
 
 export {
   userHistoryListValidator,
-  userHistoryRemoveValidator
+  userHistoryRemoveElementValidator,
+  userHistoryRemoveAllValidator
 }