diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 13:26:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 14:14:16 +0200 |
commit | 6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch) | |
tree | 3365a96d82bc7f00ae504a568725c8e914150cf8 /server/controllers/api/remote/pods.ts | |
parent | 5fe7e898316e18369c3e1aba307b55077adc7bfb (diff) | |
download | PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip |
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server/controllers/api/remote/pods.ts')
-rw-r--r-- | server/controllers/api/remote/pods.ts | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/server/controllers/api/remote/pods.ts b/server/controllers/api/remote/pods.ts index b0d6642c1..6319957d3 100644 --- a/server/controllers/api/remote/pods.ts +++ b/server/controllers/api/remote/pods.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as waterfall from 'async/waterfall' | ||
3 | 2 | ||
4 | import { database as db } from '../../../initializers/database' | 3 | import { database as db } from '../../../initializers/database' |
5 | import { checkSignature, signatureValidator } from '../../../middlewares' | 4 | import { checkSignature, signatureValidator } from '../../../middlewares' |
@@ -24,17 +23,10 @@ export { | |||
24 | function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { | 23 | function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { |
25 | const host = req.body.signature.host | 24 | const host = req.body.signature.host |
26 | 25 | ||
27 | waterfall([ | 26 | db.Pod.loadByHost(host) |
28 | function loadPod (callback) { | 27 | .then(pod => { |
29 | db.Pod.loadByHost(host, callback) | 28 | return pod.destroy() |
30 | }, | 29 | }) |
31 | 30 | .then(() => res.type('json').status(204).end()) | |
32 | function deletePod (pod, callback) { | 31 | .catch(err => next(err)) |
33 | pod.destroy().asCallback(callback) | ||
34 | } | ||
35 | ], function (err) { | ||
36 | if (err) return next(err) | ||
37 | |||
38 | return res.type('json').status(204).end() | ||
39 | }) | ||
40 | } | 32 | } |