diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/server/follows.ts | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 37647622b..e7fd3aabd 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -19,7 +19,8 @@ import { | |||
19 | followingSortValidator, | 19 | followingSortValidator, |
20 | followValidator, | 20 | followValidator, |
21 | getFollowerValidator, | 21 | getFollowerValidator, |
22 | removeFollowingValidator | 22 | removeFollowingValidator, |
23 | listFollowsValidator | ||
23 | } from '../../../middlewares/validators' | 24 | } from '../../../middlewares/validators' |
24 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 25 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
25 | import { JobQueue } from '../../../lib/job-queue' | 26 | import { JobQueue } from '../../../lib/job-queue' |
@@ -29,6 +30,7 @@ import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' | |||
29 | 30 | ||
30 | const serverFollowsRouter = express.Router() | 31 | const serverFollowsRouter = express.Router() |
31 | serverFollowsRouter.get('/following', | 32 | serverFollowsRouter.get('/following', |
33 | listFollowsValidator, | ||
32 | paginationValidator, | 34 | paginationValidator, |
33 | followingSortValidator, | 35 | followingSortValidator, |
34 | setDefaultSort, | 36 | setDefaultSort, |
@@ -52,6 +54,7 @@ serverFollowsRouter.delete('/following/:host', | |||
52 | ) | 54 | ) |
53 | 55 | ||
54 | serverFollowsRouter.get('/followers', | 56 | serverFollowsRouter.get('/followers', |
57 | listFollowsValidator, | ||
55 | paginationValidator, | 58 | paginationValidator, |
56 | followersSortValidator, | 59 | followersSortValidator, |
57 | setDefaultSort, | 60 | setDefaultSort, |
@@ -92,26 +95,28 @@ export { | |||
92 | 95 | ||
93 | async function listFollowing (req: express.Request, res: express.Response) { | 96 | async function listFollowing (req: express.Request, res: express.Response) { |
94 | const serverActor = await getServerActor() | 97 | const serverActor = await getServerActor() |
95 | const resultList = await ActorFollowModel.listFollowingForApi( | 98 | const resultList = await ActorFollowModel.listFollowingForApi({ |
96 | serverActor.id, | 99 | id: serverActor.id, |
97 | req.query.start, | 100 | start: req.query.start, |
98 | req.query.count, | 101 | count: req.query.count, |
99 | req.query.sort, | 102 | sort: req.query.sort, |
100 | req.query.search | 103 | search: req.query.search, |
101 | ) | 104 | state: req.query.state |
105 | }) | ||
102 | 106 | ||
103 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 107 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
104 | } | 108 | } |
105 | 109 | ||
106 | async function listFollowers (req: express.Request, res: express.Response) { | 110 | async function listFollowers (req: express.Request, res: express.Response) { |
107 | const serverActor = await getServerActor() | 111 | const serverActor = await getServerActor() |
108 | const resultList = await ActorFollowModel.listFollowersForApi( | 112 | const resultList = await ActorFollowModel.listFollowersForApi({ |
109 | serverActor.id, | 113 | actorId: serverActor.id, |
110 | req.query.start, | 114 | start: req.query.start, |
111 | req.query.count, | 115 | count: req.query.count, |
112 | req.query.sort, | 116 | sort: req.query.sort, |
113 | req.query.search | 117 | search: req.query.search, |
114 | ) | 118 | state: req.query.state |
119 | }) | ||
115 | 120 | ||
116 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 121 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
117 | } | 122 | } |