diff options
author | Green-Star <Green-Star@users.noreply.github.com> | 2017-08-02 21:50:42 +0200 |
---|---|---|
committer | Bigard Florian <florian.bigard@gmail.com> | 2017-08-02 21:50:42 +0200 |
commit | d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f (patch) | |
tree | bc945e1b6ab0f9cb36a481fea56cdfdaa8b1a341 /server/middlewares/validators/pods.ts | |
parent | 291e8d3eed88fe714fb74ad897ac2c67347a85ff (diff) | |
download | PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.gz PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.zst PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.zip |
Remove one pod (#76)
* Client: Fix typo
* Client: Add removeFriend feature
* Server: Add removeFriend feature
* Server: Update method name
* Fix rebase onto develop issues
* Server: Fix error message
* Server: Remove useless methods in removeFriend method
* Server: Finish remove on pod feature after rebase
* Server: Type pod parameter
* Fix Travis build
* Add friend-basic test for the remove one pod feature
* Add check-params tests for the remove one pod feature
* Fix typos
* Add friend-advanced test for the remove one pod feature
* Client: Trailing new line
* Move to promises
* Add undefined id test
* Use find method instead of a for loop to find the friend to remove
* Remove setTimeout method
* Server: Remove requestScheduler operations
* Server: Fix logging messages
* Server: Remove sign request parameter
Diffstat (limited to 'server/middlewares/validators/pods.ts')
-rw-r--r-- | server/middlewares/validators/pods.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts index 481a66957..d0981cd57 100644 --- a/server/middlewares/validators/pods.ts +++ b/server/middlewares/validators/pods.ts | |||
@@ -58,9 +58,33 @@ function podsAddValidator (req: express.Request, res: express.Response, next: ex | |||
58 | }) | 58 | }) |
59 | } | 59 | } |
60 | 60 | ||
61 | function podRemoveValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
62 | req.checkParams('id', 'Should have a valid id').notEmpty().isNumeric() | ||
63 | |||
64 | logger.debug('Checking podRemoveValidator parameters', { parameters: req.params }) | ||
65 | |||
66 | checkErrors(req, res, function () { | ||
67 | db.Pod.load(req.params.id) | ||
68 | .then(pod => { | ||
69 | if (!pod) { | ||
70 | logger.error('Cannot find pod %d.', req.params.id) | ||
71 | return res.sendStatus(404) | ||
72 | } | ||
73 | |||
74 | res.locals.pod = pod | ||
75 | return next() | ||
76 | }) | ||
77 | .catch(err => { | ||
78 | logger.error('Cannot load pod %d.', req.params.id, err) | ||
79 | res.sendStatus(500) | ||
80 | }) | ||
81 | }) | ||
82 | } | ||
83 | |||
61 | // --------------------------------------------------------------------------- | 84 | // --------------------------------------------------------------------------- |
62 | 85 | ||
63 | export { | 86 | export { |
64 | makeFriendsValidator, | 87 | makeFriendsValidator, |
65 | podsAddValidator | 88 | podsAddValidator, |
89 | podRemoveValidator | ||
66 | } | 90 | } |