diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-10 14:34:45 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 0d0e8dd0904b380b70e19ebcb4763d65601c4632 (patch) | |
tree | acb625d7c88fbe863fa14bf6783fafe4a8e35137 /server/controllers/activitypub/pods.ts | |
parent | e4f97babf701481b55cc10fb3448feab5f97c867 (diff) | |
download | PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.gz PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.zst PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.zip |
Continue activitypub
Diffstat (limited to 'server/controllers/activitypub/pods.ts')
-rw-r--r-- | server/controllers/activitypub/pods.ts | 138 |
1 files changed, 69 insertions, 69 deletions
diff --git a/server/controllers/activitypub/pods.ts b/server/controllers/activitypub/pods.ts index 326eb61ac..6cce57c1c 100644 --- a/server/controllers/activitypub/pods.ts +++ b/server/controllers/activitypub/pods.ts | |||
@@ -1,69 +1,69 @@ | |||
1 | import * as express from 'express' | 1 | // import * as express from 'express' |
2 | 2 | // | |
3 | import { database as db } from '../../../initializers/database' | 3 | // import { database as db } from '../../../initializers/database' |
4 | import { | 4 | // import { |
5 | checkSignature, | 5 | // checkSignature, |
6 | signatureValidator, | 6 | // signatureValidator, |
7 | setBodyHostPort, | 7 | // setBodyHostPort, |
8 | remotePodsAddValidator, | 8 | // remotePodsAddValidator, |
9 | asyncMiddleware | 9 | // asyncMiddleware |
10 | } from '../../../middlewares' | 10 | // } from '../../../middlewares' |
11 | import { sendOwnedDataToPod } from '../../../lib' | 11 | // import { sendOwnedDataToPod } from '../../../lib' |
12 | import { getMyPublicCert, getFormattedObjects } from '../../../helpers' | 12 | // import { getMyPublicCert, getFormattedObjects } from '../../../helpers' |
13 | import { CONFIG } from '../../../initializers' | 13 | // import { CONFIG } from '../../../initializers' |
14 | import { PodInstance } from '../../../models' | 14 | // import { PodInstance } from '../../../models' |
15 | import { PodSignature, Pod as FormattedPod } from '../../../../shared' | 15 | // import { PodSignature, Pod as FormattedPod } from '../../../../shared' |
16 | 16 | // | |
17 | const remotePodsRouter = express.Router() | 17 | // const remotePodsRouter = express.Router() |
18 | 18 | // | |
19 | remotePodsRouter.post('/remove', | 19 | // remotePodsRouter.post('/remove', |
20 | signatureValidator, | 20 | // signatureValidator, |
21 | checkSignature, | 21 | // checkSignature, |
22 | asyncMiddleware(removePods) | 22 | // asyncMiddleware(removePods) |
23 | ) | 23 | // ) |
24 | 24 | // | |
25 | remotePodsRouter.post('/list', | 25 | // remotePodsRouter.post('/list', |
26 | asyncMiddleware(remotePodsList) | 26 | // asyncMiddleware(remotePodsList) |
27 | ) | 27 | // ) |
28 | 28 | // | |
29 | remotePodsRouter.post('/add', | 29 | // remotePodsRouter.post('/add', |
30 | setBodyHostPort, // We need to modify the host before running the validator! | 30 | // setBodyHostPort, // We need to modify the host before running the validator! |
31 | remotePodsAddValidator, | 31 | // remotePodsAddValidator, |
32 | asyncMiddleware(addPods) | 32 | // asyncMiddleware(addPods) |
33 | ) | 33 | // ) |
34 | 34 | // | |
35 | // --------------------------------------------------------------------------- | 35 | // // --------------------------------------------------------------------------- |
36 | 36 | // | |
37 | export { | 37 | // export { |
38 | remotePodsRouter | 38 | // remotePodsRouter |
39 | } | 39 | // } |
40 | 40 | // | |
41 | // --------------------------------------------------------------------------- | 41 | // // --------------------------------------------------------------------------- |
42 | 42 | // | |
43 | async function addPods (req: express.Request, res: express.Response, next: express.NextFunction) { | 43 | // async function addPods (req: express.Request, res: express.Response, next: express.NextFunction) { |
44 | const information = req.body | 44 | // const information = req.body |
45 | 45 | // | |
46 | const pod = db.Pod.build(information) | 46 | // const pod = db.Pod.build(information) |
47 | const podCreated = await pod.save() | 47 | // const podCreated = await pod.save() |
48 | 48 | // | |
49 | await sendOwnedDataToPod(podCreated.id) | 49 | // await sendOwnedDataToPod(podCreated.id) |
50 | 50 | // | |
51 | const cert = await getMyPublicCert() | 51 | // const cert = await getMyPublicCert() |
52 | return res.json({ cert, email: CONFIG.ADMIN.EMAIL }) | 52 | // return res.json({ cert, email: CONFIG.ADMIN.EMAIL }) |
53 | } | 53 | // } |
54 | 54 | // | |
55 | async function remotePodsList (req: express.Request, res: express.Response, next: express.NextFunction) { | 55 | // async function remotePodsList (req: express.Request, res: express.Response, next: express.NextFunction) { |
56 | const pods = await db.Pod.list() | 56 | // const pods = await db.Pod.list() |
57 | 57 | // | |
58 | return res.json(getFormattedObjects<FormattedPod, PodInstance>(pods, pods.length)) | 58 | // return res.json(getFormattedObjects<FormattedPod, PodInstance>(pods, pods.length)) |
59 | } | 59 | // } |
60 | 60 | // | |
61 | async function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { | 61 | // async function removePods (req: express.Request, res: express.Response, next: express.NextFunction) { |
62 | const signature: PodSignature = req.body.signature | 62 | // const signature: PodSignature = req.body.signature |
63 | const host = signature.host | 63 | // const host = signature.host |
64 | 64 | // | |
65 | const pod = await db.Pod.loadByHost(host) | 65 | // const pod = await db.Pod.loadByHost(host) |
66 | await pod.destroy() | 66 | // await pod.destroy() |
67 | 67 | // | |
68 | return res.type('json').status(204).end() | 68 | // return res.type('json').status(204).end() |
69 | } | 69 | // } |