From 927fa4b11f692174d6296aa096d7a74bacdeea8b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 26 Jul 2022 14:46:15 +0200 Subject: Add rejected state to follows Prevent reprocessing already rejected follows --- server/lib/activitypub/process/process-follow.ts | 5 +++++ server/lib/activitypub/process/process-reject.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 93df7e191..a1958f464 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts @@ -58,6 +58,11 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ transaction: t }) + // Already rejected + if (actorFollow.state === 'rejected') { + return { actorFollow: undefined as MActorFollowActors } + } + // Set the follow as accepted if the remote actor follows a channel or account // Or if the instance automatically accepts followers if (actorFollow.state !== 'accepted' && (isFollowingInstance === false || CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === false)) { diff --git a/server/lib/activitypub/process/process-reject.ts b/server/lib/activitypub/process/process-reject.ts index 7f7ab305f..db7ff24d8 100644 --- a/server/lib/activitypub/process/process-reject.ts +++ b/server/lib/activitypub/process/process-reject.ts @@ -25,7 +25,8 @@ async function processReject (follower: MActor, targetActor: MActor) { if (!actorFollow) throw new Error(`'Unknown actor follow ${follower.id} -> ${targetActor.id}.`) - await actorFollow.destroy({ transaction: t }) + actorFollow.state = 'rejected' + await actorFollow.save({ transaction: t }) return undefined }) -- cgit v1.2.3