From 8424c4026afd7304880a4ce8138a04ffb3d8c938 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 30 Aug 2019 16:50:12 +0200 Subject: Add auto follow back support for instances --- server/controllers/api/config.ts | 12 ++++++++++++ server/controllers/api/server/follows.ts | 3 +++ server/controllers/api/users/my-notifications.ts | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'server/controllers') diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 21fa85a08..0c52bfa7a 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -300,6 +300,18 @@ function customConfig (): CustomConfig { enabled: CONFIG.FOLLOWERS.INSTANCE.ENABLED, manualApproval: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL } + }, + followings: { + instance: { + autoFollowBack: { + enabled: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_BACK.ENABLED + }, + + autoFollowIndex: { + enabled: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.ENABLED, + indexUrl: CONFIG.FOLLOWINGS.INSTANCE.AUTO_FOLLOW_INDEX.INDEX_URL + } + } } } } diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index d38ce91de..37647622b 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts @@ -25,6 +25,7 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { JobQueue } from '../../../lib/job-queue' import { removeRedundancyOf } from '../../../lib/redundancy' import { sequelizeTypescript } from '../../../initializers/database' +import { autoFollowBackIfNeeded } from '../../../lib/activitypub/follow' const serverFollowsRouter = express.Router() serverFollowsRouter.get('/following', @@ -172,5 +173,7 @@ async function acceptFollower (req: express.Request, res: express.Response) { follow.state = 'accepted' await follow.save() + await autoFollowBackIfNeeded(follow) + return res.status(204).end() } diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts index f146284e4..017f5219e 100644 --- a/server/controllers/api/users/my-notifications.ts +++ b/server/controllers/api/users/my-notifications.ts @@ -76,7 +76,8 @@ async function updateNotificationSettings (req: express.Request, res: express.Re newFollow: body.newFollow, newUserRegistration: body.newUserRegistration, commentMention: body.commentMention, - newInstanceFollower: body.newInstanceFollower + newInstanceFollower: body.newInstanceFollower, + autoInstanceFollowing: body.autoInstanceFollowing } await UserNotificationSettingModel.update(values, query) -- cgit v1.2.3