aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/config.ts3
-rw-r--r--server/controllers/api/server/follows.ts38
2 files changed, 35 insertions, 6 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index f9bb0b947..5c4f455ee 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -282,7 +282,8 @@ function customConfig (): CustomConfig {
282 }, 282 },
283 followers: { 283 followers: {
284 instance: { 284 instance: {
285 enabled: CONFIG.FOLLOWERS.INSTANCE.ENABLED 285 enabled: CONFIG.FOLLOWERS.INSTANCE.ENABLED,
286 manualApproval: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
286 } 287 }
287 } 288 }
288 } 289 }
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index 87cf091cb..207a09a4c 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -3,7 +3,7 @@ import { UserRight } from '../../../../shared/models/users'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 4import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
5import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../../../initializers' 5import { sequelizeTypescript, SERVER_ACTOR_NAME } from '../../../initializers'
6import { sendReject, sendUndoFollow } from '../../../lib/activitypub/send' 6import { sendAccept, sendReject, sendUndoFollow } from '../../../lib/activitypub/send'
7import { 7import {
8 asyncMiddleware, 8 asyncMiddleware,
9 authenticate, 9 authenticate,
@@ -14,10 +14,11 @@ import {
14 setDefaultSort 14 setDefaultSort
15} from '../../../middlewares' 15} from '../../../middlewares'
16import { 16import {
17 acceptOrRejectFollowerValidator,
17 followersSortValidator, 18 followersSortValidator,
18 followingSortValidator, 19 followingSortValidator,
19 followValidator, 20 followValidator,
20 removeFollowerValidator, 21 getFollowerValidator,
21 removeFollowingValidator 22 removeFollowingValidator
22} from '../../../middlewares/validators' 23} from '../../../middlewares/validators'
23import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 24import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
@@ -59,8 +60,24 @@ serverFollowsRouter.get('/followers',
59serverFollowsRouter.delete('/followers/:nameWithHost', 60serverFollowsRouter.delete('/followers/:nameWithHost',
60 authenticate, 61 authenticate,
61 ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW), 62 ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
62 asyncMiddleware(removeFollowerValidator), 63 asyncMiddleware(getFollowerValidator),
63 asyncMiddleware(removeFollower) 64 asyncMiddleware(removeOrRejectFollower)
65)
66
67serverFollowsRouter.post('/followers/:nameWithHost/reject',
68 authenticate,
69 ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
70 asyncMiddleware(getFollowerValidator),
71 acceptOrRejectFollowerValidator,
72 asyncMiddleware(removeOrRejectFollower)
73)
74
75serverFollowsRouter.post('/followers/:nameWithHost/accept',
76 authenticate,
77 ensureUserHasRight(UserRight.MANAGE_SERVER_FOLLOW),
78 asyncMiddleware(getFollowerValidator),
79 acceptOrRejectFollowerValidator,
80 asyncMiddleware(acceptFollower)
64) 81)
65 82
66// --------------------------------------------------------------------------- 83// ---------------------------------------------------------------------------
@@ -136,7 +153,7 @@ async function removeFollowing (req: express.Request, res: express.Response) {
136 return res.status(204).end() 153 return res.status(204).end()
137} 154}
138 155
139async function removeFollower (req: express.Request, res: express.Response) { 156async function removeOrRejectFollower (req: express.Request, res: express.Response) {
140 const follow = res.locals.follow 157 const follow = res.locals.follow
141 158
142 await sendReject(follow.ActorFollower, follow.ActorFollowing) 159 await sendReject(follow.ActorFollower, follow.ActorFollowing)
@@ -145,3 +162,14 @@ async function removeFollower (req: express.Request, res: express.Response) {
145 162
146 return res.status(204).end() 163 return res.status(204).end()
147} 164}
165
166async function acceptFollower (req: express.Request, res: express.Response) {
167 const follow = res.locals.follow
168
169 await sendAccept(follow)
170
171 follow.state = 'accepted'
172 await follow.save()
173
174 return res.status(204).end()
175}