aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-01-18 11:23:41 +0100
committerChocobozzz <me@florianbigard.com>2022-01-18 11:23:41 +0100
commit7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180 (patch)
tree016cb0d966fe9fea8a6381eb246e966f5c4eae57 /server/middlewares/validators
parent3b83faccfffc13adaef0b63c211b1ce4944e8b3b (diff)
downloadPeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.tar.gz
PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.tar.zst
PeerTube-7177b46ca1b35aa9d7ed39a06c1dcf41a4fc6180.zip
Add ability to delete history element
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/user-history.ts24
1 files changed, 19 insertions, 5 deletions
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index f9be26627..541910be5 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -1,6 +1,6 @@
1import express from 'express' 1import express from 'express'
2import { body, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { exists, isDateValid } from '../../helpers/custom-validators/misc' 3import { exists, isDateValid, isIdValid } from '../../helpers/custom-validators/misc'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './shared' 5import { areValidationErrors } from './shared'
6 6
@@ -18,13 +18,26 @@ const userHistoryListValidator = [
18 } 18 }
19] 19]
20 20
21const userHistoryRemoveValidator = [ 21const userHistoryRemoveAllValidator = [
22 body('beforeDate') 22 body('beforeDate')
23 .optional() 23 .optional()
24 .custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'), 24 .custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'),
25 25
26 (req: express.Request, res: express.Response, next: express.NextFunction) => { 26 (req: express.Request, res: express.Response, next: express.NextFunction) => {
27 logger.debug('Checking userHistoryRemoveValidator parameters', { parameters: req.body }) 27 logger.debug('Checking userHistoryRemoveAllValidator parameters', { parameters: req.body })
28
29 if (areValidationErrors(req, res)) return
30
31 return next()
32 }
33]
34
35const userHistoryRemoveElementValidator = [
36 param('videoId')
37 .custom(isIdValid).withMessage('Should have a valid video id'),
38
39 (req: express.Request, res: express.Response, next: express.NextFunction) => {
40 logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params })
28 41
29 if (areValidationErrors(req, res)) return 42 if (areValidationErrors(req, res)) return
30 43
@@ -36,5 +49,6 @@ const userHistoryRemoveValidator = [
36 49
37export { 50export {
38 userHistoryListValidator, 51 userHistoryListValidator,
39 userHistoryRemoveValidator 52 userHistoryRemoveElementValidator,
53 userHistoryRemoveAllValidator
40} 54}