aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts4
-rw-r--r--server/controllers/activitypub/index.ts5
-rw-r--r--server/controllers/api/application/follows.ts (renamed from server/controllers/api/pods.ts)50
-rw-r--r--server/controllers/api/application/index.ts12
-rw-r--r--server/controllers/api/index.ts4
-rw-r--r--server/controllers/webfinger.ts2
6 files changed, 43 insertions, 34 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 56a4054fa..49dd24e79 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -46,7 +46,7 @@ async function accountFollowersController (req: express.Request, res: express.Re
46 const page = req.params.page || 1 46 const page = req.params.page || 1
47 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) 47 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
48 48
49 const result = await db.Account.listAcceptedFollowerUrlsForApi(account.id, start, count) 49 const result = await db.AccountFollow.listAcceptedFollowerUrlsForApi(account.id, start, count)
50 const activityPubResult = activityPubCollectionPagination(req.url, page, result) 50 const activityPubResult = activityPubCollectionPagination(req.url, page, result)
51 51
52 return res.json(activityPubResult) 52 return res.json(activityPubResult)
@@ -58,7 +58,7 @@ async function accountFollowingController (req: express.Request, res: express.Re
58 const page = req.params.page || 1 58 const page = req.params.page || 1
59 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) 59 const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
60 60
61 const result = await db.Account.listAcceptedFollowingUrlsForApi(account.id, start, count) 61 const result = await db.AccountFollow.listAcceptedFollowingUrlsForApi(account.id, start, count)
62 const activityPubResult = activityPubCollectionPagination(req.url, page, result) 62 const activityPubResult = activityPubCollectionPagination(req.url, page, result)
63 63
64 return res.json(activityPubResult) 64 return res.json(activityPubResult)
diff --git a/server/controllers/activitypub/index.ts b/server/controllers/activitypub/index.ts
index 0c8574ef7..c5bec6448 100644
--- a/server/controllers/activitypub/index.ts
+++ b/server/controllers/activitypub/index.ts
@@ -1,14 +1,11 @@
1import * as express from 'express' 1import * as express from 'express'
2
3import { badRequest } from '../../helpers'
4import { inboxRouter } from './inbox'
5import { activityPubClientRouter } from './client' 2import { activityPubClientRouter } from './client'
3import { inboxRouter } from './inbox'
6 4
7const activityPubRouter = express.Router() 5const activityPubRouter = express.Router()
8 6
9activityPubRouter.use('/', inboxRouter) 7activityPubRouter.use('/', inboxRouter)
10activityPubRouter.use('/', activityPubClientRouter) 8activityPubRouter.use('/', activityPubClientRouter)
11activityPubRouter.use('/*', badRequest)
12 9
13// --------------------------------------------------------------------------- 10// ---------------------------------------------------------------------------
14 11
diff --git a/server/controllers/api/pods.ts b/server/controllers/api/application/follows.ts
index 0bd6971bb..000bbd23e 100644
--- a/server/controllers/api/pods.ts
+++ b/server/controllers/api/application/follows.ts
@@ -1,23 +1,23 @@
1import * as express from 'express' 1import * as express from 'express'
2import { UserRight } from '../../../shared/models/users/user-right.enum' 2import { UserRight } from '../../../../shared/models/users/user-right.enum'
3import { getFormattedObjects } from '../../helpers' 3import { getFormattedObjects } from '../../../helpers'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { getApplicationAccount } from '../../helpers/utils' 5import { getApplicationAccount } from '../../../helpers/utils'
6import { getAccountFromWebfinger } from '../../helpers/webfinger' 6import { getAccountFromWebfinger } from '../../../helpers/webfinger'
7import { SERVER_ACCOUNT_NAME } from '../../initializers/constants' 7import { SERVER_ACCOUNT_NAME } from '../../../initializers/constants'
8import { database as db } from '../../initializers/database' 8import { database as db } from '../../../initializers/database'
9import { sendFollow } from '../../lib/activitypub/send-request' 9import { sendFollow } from '../../../lib/activitypub/send-request'
10import { asyncMiddleware, paginationValidator, setFollowersSort, setPagination } from '../../middlewares' 10import { asyncMiddleware, paginationValidator, setFollowersSort, setPagination } from '../../../middlewares'
11import { authenticate } from '../../middlewares/oauth' 11import { authenticate } from '../../../middlewares/oauth'
12import { setBodyHostsPort } from '../../middlewares/pods' 12import { setBodyHostsPort } from '../../../middlewares/pods'
13import { setFollowingSort } from '../../middlewares/sort' 13import { setFollowingSort } from '../../../middlewares/sort'
14import { ensureUserHasRight } from '../../middlewares/user-right' 14import { ensureUserHasRight } from '../../../middlewares/user-right'
15import { followValidator } from '../../middlewares/validators/pods' 15import { followValidator } from '../../../middlewares/validators/pods'
16import { followersSortValidator, followingSortValidator } from '../../middlewares/validators/sort' 16import { followersSortValidator, followingSortValidator } from '../../../middlewares/validators/sort'
17 17
18const podsRouter = express.Router() 18const applicationFollowsRouter = express.Router()
19 19
20podsRouter.get('/following', 20applicationFollowsRouter.get('/following',
21 paginationValidator, 21 paginationValidator,
22 followingSortValidator, 22 followingSortValidator,
23 setFollowingSort, 23 setFollowingSort,
@@ -25,15 +25,15 @@ podsRouter.get('/following',
25 asyncMiddleware(listFollowing) 25 asyncMiddleware(listFollowing)
26) 26)
27 27
28podsRouter.post('/follow', 28applicationFollowsRouter.post('/follow',
29 authenticate, 29 authenticate,
30 ensureUserHasRight(UserRight.MANAGE_PEERTUBE_FOLLOW), 30 ensureUserHasRight(UserRight.MANAGE_APPLICATION_FOLLOW),
31 followValidator, 31 followValidator,
32 setBodyHostsPort, 32 setBodyHostsPort,
33 asyncMiddleware(follow) 33 asyncMiddleware(follow)
34) 34)
35 35
36podsRouter.get('/followers', 36applicationFollowsRouter.get('/followers',
37 paginationValidator, 37 paginationValidator,
38 followersSortValidator, 38 followersSortValidator,
39 setFollowersSort, 39 setFollowersSort,
@@ -44,21 +44,21 @@ podsRouter.get('/followers',
44// --------------------------------------------------------------------------- 44// ---------------------------------------------------------------------------
45 45
46export { 46export {
47 podsRouter 47 applicationFollowsRouter
48} 48}
49 49
50// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
51 51
52async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) { 52async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
53 const applicationAccount = await getApplicationAccount() 53 const applicationAccount = await getApplicationAccount()
54 const resultList = await db.Account.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) 54 const resultList = await db.AccountFollow.listFollowingForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
55 55
56 return res.json(getFormattedObjects(resultList.data, resultList.total)) 56 return res.json(getFormattedObjects(resultList.data, resultList.total))
57} 57}
58 58
59async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) { 59async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
60 const applicationAccount = await getApplicationAccount() 60 const applicationAccount = await getApplicationAccount()
61 const resultList = await db.Account.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort) 61 const resultList = await db.AccountFollow.listFollowersForApi(applicationAccount.id, req.query.start, req.query.count, req.query.sort)
62 62
63 return res.json(getFormattedObjects(resultList.data, resultList.total)) 63 return res.json(getFormattedObjects(resultList.data, resultList.total))
64} 64}
diff --git a/server/controllers/api/application/index.ts b/server/controllers/api/application/index.ts
new file mode 100644
index 000000000..011b971ed
--- /dev/null
+++ b/server/controllers/api/application/index.ts
@@ -0,0 +1,12 @@
1import * as express from 'express'
2import { applicationFollowsRouter } from './follows'
3
4const applicationRouter = express.Router()
5
6applicationRouter.use('/', applicationFollowsRouter)
7
8// ---------------------------------------------------------------------------
9
10export {
11 applicationRouter
12}
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 2e949d531..a22c78cce 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -4,15 +4,15 @@ import { badRequest } from '../../helpers'
4 4
5import { oauthClientsRouter } from './oauth-clients' 5import { oauthClientsRouter } from './oauth-clients'
6import { configRouter } from './config' 6import { configRouter } from './config'
7import { podsRouter } from './pods' 7import { applicationRouter } from './application'
8import { usersRouter } from './users' 8import { usersRouter } from './users'
9import { videosRouter } from './videos' 9import { videosRouter } from './videos'
10 10
11const apiRouter = express.Router() 11const apiRouter = express.Router()
12 12
13apiRouter.use('/application', applicationRouter)
13apiRouter.use('/oauth-clients', oauthClientsRouter) 14apiRouter.use('/oauth-clients', oauthClientsRouter)
14apiRouter.use('/config', configRouter) 15apiRouter.use('/config', configRouter)
15apiRouter.use('/pods', podsRouter)
16apiRouter.use('/users', usersRouter) 16apiRouter.use('/users', usersRouter)
17apiRouter.use('/videos', videosRouter) 17apiRouter.use('/videos', videosRouter)
18apiRouter.use('/ping', pong) 18apiRouter.use('/ping', pong)
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts
index 1c726f0cb..102ac0937 100644
--- a/server/controllers/webfinger.ts
+++ b/server/controllers/webfinger.ts
@@ -8,7 +8,7 @@ import { AccountInstance } from '../models/account/account-interface'
8 8
9const webfingerRouter = express.Router() 9const webfingerRouter = express.Router()
10 10
11webfingerRouter.use('/.well-known/webfinger', 11webfingerRouter.get('/.well-known/webfinger',
12 webfingerValidator, 12 webfingerValidator,
13 webfingerController 13 webfingerController
14) 14)