From d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f Mon Sep 17 00:00:00 2001 From: Green-Star Date: Wed, 2 Aug 2017 21:50:42 +0200 Subject: 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 --- server/controllers/api/pods.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'server/controllers/api/pods.ts') diff --git a/server/controllers/api/pods.ts b/server/controllers/api/pods.ts index 5210f9fe4..916b131d9 100644 --- a/server/controllers/api/pods.ts +++ b/server/controllers/api/pods.ts @@ -10,7 +10,8 @@ import { import { sendOwnedVideosToPod, makeFriends, - quitFriends + quitFriends, + removeFriend } from '../../lib' import { podsAddValidator, @@ -18,7 +19,8 @@ import { ensureIsAdmin, makeFriendsValidator, setBodyHostPort, - setBodyHostsPort + setBodyHostsPort, + podRemoveValidator } from '../../middlewares' import { PodInstance @@ -45,6 +47,12 @@ podsRouter.get('/quitfriends', ensureIsAdmin, quitFriendsController ) +podsRouter.delete('/:id', + authenticate, + ensureIsAdmin, + podRemoveValidator, + removeFriendController +) // --------------------------------------------------------------------------- @@ -93,3 +101,11 @@ function quitFriendsController (req: express.Request, res: express.Response, nex .then(() => res.type('json').status(204).end()) .catch(err => next(err)) } + +function removeFriendController (req: express.Request, res: express.Response, next: express.NextFunction) { + const pod = res.locals.pod as PodInstance + + removeFriend(pod) + .then(() => (res.type('json').status(204).end())) + .catch(err => next(err)) +} -- cgit v1.2.3