aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-13 17:39:41 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit7a7724e66e4533523083e7336cd0d0c747c4a33b (patch)
tree805299eb9c6829158cd17e5a823a84a3a54d8209 /server/controllers/api
parent571389d43b8fc8aaf27e77c06f19b320b08dbbc9 (diff)
downloadPeerTube-7a7724e66e4533523083e7336cd0d0c747c4a33b.tar.gz
PeerTube-7a7724e66e4533523083e7336cd0d0c747c4a33b.tar.zst
PeerTube-7a7724e66e4533523083e7336cd0d0c747c4a33b.zip
Handle follow/accept
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/pods.ts33
1 files changed, 26 insertions, 7 deletions
diff --git a/server/controllers/api/pods.ts b/server/controllers/api/pods.ts
index 43df3f66f..aa07b17f6 100644
--- a/server/controllers/api/pods.ts
+++ b/server/controllers/api/pods.ts
@@ -1,16 +1,27 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getFormattedObjects } from '../../helpers' 2import { getFormattedObjects } from '../../helpers'
3import { getApplicationAccount } from '../../helpers/utils'
3import { database as db } from '../../initializers/database' 4import { database as db } from '../../initializers/database'
4import { asyncMiddleware, paginationValidator, podsSortValidator, setPagination, setPodsSort } from '../../middlewares' 5import { asyncMiddleware, paginationValidator, setFollowersSort, setPagination } from '../../middlewares'
6import { setFollowingSort } from '../../middlewares/sort'
7import { followersSortValidator, followingSortValidator } from '../../middlewares/validators/sort'
5 8
6const podsRouter = express.Router() 9const podsRouter = express.Router()
7 10
8podsRouter.get('/', 11podsRouter.get('/following',
9 paginationValidator, 12 paginationValidator,
10 podsSortValidator, 13 followingSortValidator,
11 setPodsSort, 14 setFollowingSort,
12 setPagination, 15 setPagination,
13 asyncMiddleware(listPods) 16 asyncMiddleware(listFollowing)
17)
18
19podsRouter.get('/followers',
20 paginationValidator,
21 followersSortValidator,
22 setFollowersSort,
23 setPagination,
24 asyncMiddleware(listFollowers)
14) 25)
15 26
16// --------------------------------------------------------------------------- 27// ---------------------------------------------------------------------------
@@ -21,8 +32,16 @@ export {
21 32
22// --------------------------------------------------------------------------- 33// ---------------------------------------------------------------------------
23 34
24async function listPods (req: express.Request, res: express.Response, next: express.NextFunction) { 35async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
25 const resultList = await db.Pod.listForApi(req.query.start, req.query.count, req.query.sort) 36 const applicationAccount = await getApplicationAccount()
37 const resultList = await db.Account.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
38
39 return res.json(getFormattedObjects(resultList.data, resultList.total))
40}
41
42async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
43 const applicationAccount = await getApplicationAccount()
44 const resultList = await db.Account.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
26 45
27 return res.json(getFormattedObjects(resultList.data, resultList.total)) 46 return res.json(getFormattedObjects(resultList.data, resultList.total))
28} 47}