From 14893eb71cb2d4ca47e07589c81958863603aba4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Apr 2019 15:18:04 +0200 Subject: Add ability to manually approves instance followers in REST API --- server/lib/activitypub/process/process-follow.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'server/lib') diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index cecf09b47..140bbe9f1 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts @@ -32,6 +32,8 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { const serverActor = await getServerActor() if (targetActor.id === serverActor.id && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { + logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) + return sendReject(actor, targetActor) } @@ -43,7 +45,7 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { defaults: { actorId: actor.id, targetActorId: targetActor.id, - state: 'accepted' + state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL ? 'pending' : 'accepted' }, transaction: t }) @@ -51,7 +53,7 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { actorFollow.ActorFollower = actor actorFollow.ActorFollowing = targetActor - if (actorFollow.state !== 'accepted') { + if (actorFollow.state !== 'accepted' && CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === false) { actorFollow.state = 'accepted' await actorFollow.save({ transaction: t }) } @@ -60,7 +62,7 @@ async function processFollow (actor: ActorModel, targetActorURL: string) { actorFollow.ActorFollowing = targetActor // Target sends to actor he accepted the follow request - await sendAccept(actorFollow) + if (actorFollow.state === 'accepted') await sendAccept(actorFollow) return { actorFollow, created } }) -- cgit v1.2.3