aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-13 09:16:15 +0100
committerGitHub <noreply@github.com>2021-01-13 09:16:15 +0100
commitd8b34ee55b654912f86bb8b472d391ced8c28f64 (patch)
treeefa2b8ac36c00fa6e9b5af3f13e54a47bc7a7701 /server/middlewares/validators
parent22078471fbe5a4dea6177bd1fa19da1cf887679e (diff)
downloadPeerTube-d8b34ee55b654912f86bb8b472d391ced8c28f64.tar.gz
PeerTube-d8b34ee55b654912f86bb8b472d391ced8c28f64.tar.zst
PeerTube-d8b34ee55b654912f86bb8b472d391ced8c28f64.zip
Allow user to search through their watch history (#3576)
* allow user to search through their watch history * add tests for search in watch history * Update client/src/app/shared/shared-main/users/user-history.service.ts
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/user-history.ts19
1 files changed, 17 insertions, 2 deletions
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index 2f1d3cc41..058bf7758 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -1,8 +1,22 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator' 2import { body, query } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { isDateValid } from '../../helpers/custom-validators/misc' 5import { exists, isDateValid } from '../../helpers/custom-validators/misc'
6
7const userHistoryListValidator = [
8 query('search')
9 .optional()
10 .custom(exists).withMessage('Should have a valid search'),
11
12 (req: express.Request, res: express.Response, next: express.NextFunction) => {
13 logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })
14
15 if (areValidationErrors(req, res)) return
16
17 return next()
18 }
19]
6 20
7const userHistoryRemoveValidator = [ 21const userHistoryRemoveValidator = [
8 body('beforeDate') 22 body('beforeDate')
@@ -21,5 +35,6 @@ const userHistoryRemoveValidator = [
21// --------------------------------------------------------------------------- 35// ---------------------------------------------------------------------------
22 36
23export { 37export {
38 userHistoryListValidator,
24 userHistoryRemoveValidator 39 userHistoryRemoveValidator
25} 40}