diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-01-13 09:16:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-13 09:16:15 +0100 |
commit | d8b34ee55b654912f86bb8b472d391ced8c28f64 (patch) | |
tree | efa2b8ac36c00fa6e9b5af3f13e54a47bc7a7701 /server/middlewares/validators | |
parent | 22078471fbe5a4dea6177bd1fa19da1cf887679e (diff) | |
download | PeerTube-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.ts | 19 |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body, query } from 'express-validator' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { areValidationErrors } from './utils' | 4 | import { areValidationErrors } from './utils' |
5 | import { isDateValid } from '../../helpers/custom-validators/misc' | 5 | import { exists, isDateValid } from '../../helpers/custom-validators/misc' |
6 | |||
7 | const 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 | ||
7 | const userHistoryRemoveValidator = [ | 21 | const userHistoryRemoveValidator = [ |
8 | body('beforeDate') | 22 | body('beforeDate') |
@@ -21,5 +35,6 @@ const userHistoryRemoveValidator = [ | |||
21 | // --------------------------------------------------------------------------- | 35 | // --------------------------------------------------------------------------- |
22 | 36 | ||
23 | export { | 37 | export { |
38 | userHistoryListValidator, | ||
24 | userHistoryRemoveValidator | 39 | userHistoryRemoveValidator |
25 | } | 40 | } |