diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-08 15:18:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-08 15:18:04 +0200 |
commit | 14893eb71cb2d4ca47e07589c81958863603aba4 (patch) | |
tree | a6a5c3130058ca57c10ef15b8b6ee00ef78166ea /server/middlewares/validators/follows.ts | |
parent | 5b9c965d5aa747f29b081289f930ee215fdc23c8 (diff) | |
download | PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.tar.gz PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.tar.zst PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.zip |
Add ability to manually approves instance followers in REST API
Diffstat (limited to 'server/middlewares/validators/follows.ts')
-rw-r--r-- | server/middlewares/validators/follows.ts | 20 |
1 files changed, 17 insertions, 3 deletions
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 | ||
60 | const removeFollowerValidator = [ | 60 | const 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 | ||
93 | const 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 | ||
95 | export { | 108 | export { |
96 | followValidator, | 109 | followValidator, |
97 | removeFollowingValidator, | 110 | removeFollowingValidator, |
98 | removeFollowerValidator | 111 | getFollowerValidator, |
112 | acceptOrRejectFollowerValidator | ||
99 | } | 113 | } |