aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/pods.ts
diff options
context:
space:
mode:
authorGreen-Star <Green-Star@users.noreply.github.com>2017-08-02 21:50:42 +0200
committerBigard Florian <florian.bigard@gmail.com>2017-08-02 21:50:42 +0200
commitd5f5a670fcf6258d0facf9a2fd3aabd550fbc78f (patch)
treebc945e1b6ab0f9cb36a481fea56cdfdaa8b1a341 /server/controllers/api/pods.ts
parent291e8d3eed88fe714fb74ad897ac2c67347a85ff (diff)
downloadPeerTube-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/controllers/api/pods.ts')
-rw-r--r--server/controllers/api/pods.ts20
1 files changed, 18 insertions, 2 deletions
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 {
10import { 10import {
11 sendOwnedVideosToPod, 11 sendOwnedVideosToPod,
12 makeFriends, 12 makeFriends,
13 quitFriends 13 quitFriends,
14 removeFriend
14} from '../../lib' 15} from '../../lib'
15import { 16import {
16 podsAddValidator, 17 podsAddValidator,
@@ -18,7 +19,8 @@ import {
18 ensureIsAdmin, 19 ensureIsAdmin,
19 makeFriendsValidator, 20 makeFriendsValidator,
20 setBodyHostPort, 21 setBodyHostPort,
21 setBodyHostsPort 22 setBodyHostsPort,
23 podRemoveValidator
22} from '../../middlewares' 24} from '../../middlewares'
23import { 25import {
24 PodInstance 26 PodInstance
@@ -45,6 +47,12 @@ podsRouter.get('/quitfriends',
45 ensureIsAdmin, 47 ensureIsAdmin,
46 quitFriendsController 48 quitFriendsController
47) 49)
50podsRouter.delete('/:id',
51 authenticate,
52 ensureIsAdmin,
53 podRemoveValidator,
54 removeFriendController
55)
48 56
49// --------------------------------------------------------------------------- 57// ---------------------------------------------------------------------------
50 58
@@ -93,3 +101,11 @@ function quitFriendsController (req: express.Request, res: express.Response, nex
93 .then(() => res.type('json').status(204).end()) 101 .then(() => res.type('json').status(204).end())
94 .catch(err => next(err)) 102 .catch(err => next(err))
95} 103}
104
105function removeFriendController (req: express.Request, res: express.Response, next: express.NextFunction) {
106 const pod = res.locals.pod as PodInstance
107
108 removeFriend(pod)
109 .then(() => (res.type('json').status(204).end()))
110 .catch(err => next(err))
111}