aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/config.ts3
-rw-r--r--server/middlewares/validators/follows.ts20
2 files changed, 20 insertions, 3 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 270ce66f6..d015fa6fe 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -44,6 +44,9 @@ const customConfigUpdateValidator = [
44 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), 44 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'),
45 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), 45 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'),
46 46
47 body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'),
48 body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'),
49
47 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 50 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) 51 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
49 52
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 38df39fda..b360cf95e 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -57,11 +57,11 @@ const removeFollowingValidator = [
57 } 57 }
58] 58]
59 59
60const removeFollowerValidator = [ 60const getFollowerValidator = [
61 param('nameWithHost').custom(isValidActorHandle).withMessage('Should have a valid nameWithHost'), 61 param('nameWithHost').custom(isValidActorHandle).withMessage('Should have a valid nameWithHost'),
62 62
63 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 63 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
64 logger.debug('Checking remove follower parameters', { parameters: req.params }) 64 logger.debug('Checking get follower parameters', { parameters: req.params })
65 65
66 if (areValidationErrors(req, res)) return 66 if (areValidationErrors(req, res)) return
67 67
@@ -90,10 +90,24 @@ const removeFollowerValidator = [
90 } 90 }
91] 91]
92 92
93const acceptOrRejectFollowerValidator = [
94 (req: express.Request, res: express.Response, next: express.NextFunction) => {
95 logger.debug('Checking accept/reject follower parameters', { parameters: req.params })
96
97 const follow = res.locals.follow
98 if (follow.state !== 'pending') {
99 return res.status(400).json({ error: 'Follow is not in pending state.' }).end()
100 }
101
102 return next()
103 }
104]
105
93// --------------------------------------------------------------------------- 106// ---------------------------------------------------------------------------
94 107
95export { 108export {
96 followValidator, 109 followValidator,
97 removeFollowingValidator, 110 removeFollowingValidator,
98 removeFollowerValidator 111 getFollowerValidator,
112 acceptOrRejectFollowerValidator
99} 113}