diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-02 16:37:43 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | dc13348070d808d0ba3feb56a435b835c2e7e791 (patch) | |
tree | 887202a33f1aa680fd8ece6ee465381f3931c64e /server/middlewares/validators/user-notifications.ts | |
parent | 6e7e63b83f08ba68edc2bb9f72ff03d1802e45df (diff) | |
download | PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.gz PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.zst PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.zip |
Add import finished and video published notifs
Diffstat (limited to 'server/middlewares/validators/user-notifications.ts')
-rw-r--r-- | server/middlewares/validators/user-notifications.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.ts index 8202f307e..1c31f0a73 100644 --- a/server/middlewares/validators/user-notifications.ts +++ b/server/middlewares/validators/user-notifications.ts | |||
@@ -1,11 +1,26 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import 'express-validator' | 2 | import 'express-validator' |
3 | import { body } from 'express-validator/check' | 3 | import { body, query } from 'express-validator/check' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' | 6 | import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' |
7 | import { isIntArray } from '../../helpers/custom-validators/misc' | 7 | import { isIntArray } from '../../helpers/custom-validators/misc' |
8 | 8 | ||
9 | const listUserNotificationsValidator = [ | ||
10 | query('unread') | ||
11 | .optional() | ||
12 | .toBoolean() | ||
13 | .isBoolean().withMessage('Should have a valid unread boolean'), | ||
14 | |||
15 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
16 | logger.debug('Checking listUserNotificationsValidator parameters', { parameters: req.query }) | ||
17 | |||
18 | if (areValidationErrors(req, res)) return | ||
19 | |||
20 | return next() | ||
21 | } | ||
22 | ] | ||
23 | |||
9 | const updateNotificationSettingsValidator = [ | 24 | const updateNotificationSettingsValidator = [ |
10 | body('newVideoFromSubscription') | 25 | body('newVideoFromSubscription') |
11 | .custom(isUserNotificationSettingValid).withMessage('Should have a valid new video from subscription notification setting'), | 26 | .custom(isUserNotificationSettingValid).withMessage('Should have a valid new video from subscription notification setting'), |
@@ -41,6 +56,7 @@ const markAsReadUserNotificationsValidator = [ | |||
41 | // --------------------------------------------------------------------------- | 56 | // --------------------------------------------------------------------------- |
42 | 57 | ||
43 | export { | 58 | export { |
59 | listUserNotificationsValidator, | ||
44 | updateNotificationSettingsValidator, | 60 | updateNotificationSettingsValidator, |
45 | markAsReadUserNotificationsValidator | 61 | markAsReadUserNotificationsValidator |
46 | } | 62 | } |