aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-14 09:11:43 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:51 +0100
commit8e6964874990d5ee9d3703be71c6ab4617b9ce20 (patch)
tree84f45507c425d8b64ba03292cb9d49a4feaadeba /server/controllers
parentce548a10db3822c415b30ea0edb59e02a460734a (diff)
downloadPeerTube-8e6964874990d5ee9d3703be71c6ab4617b9ce20.tar.gz
PeerTube-8e6964874990d5ee9d3703be71c6ab4617b9ce20.tar.zst
PeerTube-8e6964874990d5ee9d3703be71c6ab4617b9ce20.zip
Add MANAGE_PEERTUBE_FOLLOW right
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts4
-rw-r--r--server/controllers/api/pods.ts5
2 files changed, 7 insertions, 2 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 5cfbc2f1d..461a619dd 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.listFollowerUrlsForApi(account.id, start, count) 49 const result = await db.Account.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.listFollowingUrlsForApi(account.id, start, count) 61 const result = await db.Account.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/api/pods.ts b/server/controllers/api/pods.ts
index f662f1c03..2231a05fa 100644
--- a/server/controllers/api/pods.ts
+++ b/server/controllers/api/pods.ts
@@ -11,6 +11,9 @@ import { setFollowingSort } from '../../middlewares/sort'
11import { followValidator } from '../../middlewares/validators/pods' 11import { followValidator } from '../../middlewares/validators/pods'
12import { followersSortValidator, followingSortValidator } from '../../middlewares/validators/sort' 12import { followersSortValidator, followingSortValidator } from '../../middlewares/validators/sort'
13import { sendFollow } from '../../lib/activitypub/send-request' 13import { sendFollow } from '../../lib/activitypub/send-request'
14import { authenticate } from '../../middlewares/oauth'
15import { ensureUserHasRight } from '../../middlewares/user-right'
16import { UserRight } from '../../../shared/models/users/user-right.enum'
14 17
15const podsRouter = express.Router() 18const podsRouter = express.Router()
16 19
@@ -23,6 +26,8 @@ podsRouter.get('/following',
23) 26)
24 27
25podsRouter.post('/follow', 28podsRouter.post('/follow',
29 authenticate,
30 ensureUserHasRight(UserRight.MANAGE_PEERTUBE_FOLLOW),
26 followValidator, 31 followValidator,
27 setBodyHostsPort, 32 setBodyHostsPort,
28 asyncMiddleware(follow) 33 asyncMiddleware(follow)