diff options
Diffstat (limited to 'server/middlewares/validators/video-channels.ts')
-rw-r--r-- | server/middlewares/validators/video-channels.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/server/middlewares/validators/video-channels.ts b/server/middlewares/validators/video-channels.ts index fe42105e8..e3a11a41b 100644 --- a/server/middlewares/validators/video-channels.ts +++ b/server/middlewares/validators/video-channels.ts | |||
@@ -26,6 +26,7 @@ const listVideoAccountChannelsValidator = [ | |||
26 | ] | 26 | ] |
27 | 27 | ||
28 | const videoChannelsAddValidator = [ | 28 | const videoChannelsAddValidator = [ |
29 | param('accountId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid account id'), | ||
29 | body('name').custom(isVideoChannelNameValid).withMessage('Should have a valid name'), | 30 | body('name').custom(isVideoChannelNameValid).withMessage('Should have a valid name'), |
30 | body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), | 31 | body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), |
31 | body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), | 32 | body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), |
@@ -41,6 +42,7 @@ const videoChannelsAddValidator = [ | |||
41 | 42 | ||
42 | const videoChannelsUpdateValidator = [ | 43 | const videoChannelsUpdateValidator = [ |
43 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), | 44 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), |
45 | param('accountId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid account id'), | ||
44 | body('name').optional().custom(isVideoChannelNameValid).withMessage('Should have a valid name'), | 46 | body('name').optional().custom(isVideoChannelNameValid).withMessage('Should have a valid name'), |
45 | body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), | 47 | body('description').optional().custom(isVideoChannelDescriptionValid).withMessage('Should have a valid description'), |
46 | body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), | 48 | body('support').optional().custom(isVideoChannelSupportValid).withMessage('Should have a valid support text'), |
@@ -49,6 +51,7 @@ const videoChannelsUpdateValidator = [ | |||
49 | logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body }) | 51 | logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body }) |
50 | 52 | ||
51 | if (areValidationErrors(req, res)) return | 53 | if (areValidationErrors(req, res)) return |
54 | if (!await isAccountIdExist(req.params.accountId, res)) return | ||
52 | if (!await isVideoChannelExist(req.params.id, res)) return | 55 | if (!await isVideoChannelExist(req.params.id, res)) return |
53 | 56 | ||
54 | // We need to make additional checks | 57 | // We need to make additional checks |
@@ -70,11 +73,13 @@ const videoChannelsUpdateValidator = [ | |||
70 | 73 | ||
71 | const videoChannelsRemoveValidator = [ | 74 | const videoChannelsRemoveValidator = [ |
72 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), | 75 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), |
76 | param('accountId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid account id'), | ||
73 | 77 | ||
74 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 78 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
75 | logger.debug('Checking videoChannelsRemove parameters', { parameters: req.params }) | 79 | logger.debug('Checking videoChannelsRemove parameters', { parameters: req.params }) |
76 | 80 | ||
77 | if (areValidationErrors(req, res)) return | 81 | if (areValidationErrors(req, res)) return |
82 | if (!await isAccountIdExist(req.params.accountId, res)) return | ||
78 | if (!await isVideoChannelExist(req.params.id, res)) return | 83 | if (!await isVideoChannelExist(req.params.id, res)) return |
79 | 84 | ||
80 | // Check if the user who did the request is able to delete the video | 85 | // Check if the user who did the request is able to delete the video |
@@ -87,11 +92,14 @@ const videoChannelsRemoveValidator = [ | |||
87 | 92 | ||
88 | const videoChannelsGetValidator = [ | 93 | const videoChannelsGetValidator = [ |
89 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), | 94 | param('id').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), |
95 | param('accountId').optional().custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid account id'), | ||
90 | 96 | ||
91 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 97 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
92 | logger.debug('Checking videoChannelsGet parameters', { parameters: req.params }) | 98 | logger.debug('Checking videoChannelsGet parameters', { parameters: req.params }) |
93 | 99 | ||
94 | if (areValidationErrors(req, res)) return | 100 | if (areValidationErrors(req, res)) return |
101 | // On some routes, accountId is optional (for example in the ActivityPub route) | ||
102 | if (req.params.accountId && !await isAccountIdExist(req.params.accountId, res)) return | ||
95 | if (!await isVideoChannelExist(req.params.id, res)) return | 103 | if (!await isVideoChannelExist(req.params.id, res)) return |
96 | 104 | ||
97 | return next() | 105 | return next() |