From e1a570abff3ebf375433e58e7362d56bd32d4cd8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Oct 2021 10:52:15 +0200 Subject: Fix user subscription follows count --- server/lib/activitypub/process/process-follow.ts | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'server/lib/activitypub/process/process-follow.ts') diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 5562f0798..e44590ffc 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts @@ -48,23 +48,15 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ return { actorFollow: undefined as MActorFollowActors } } - // Don't use findOrCreate by sequelize that breaks our actor follow hooks - let created = false - let actorFollow: MActorFollowActors = await ActorFollowModel.loadByActorAndTarget(byActor.id, targetActor.id, t) - - if (!actorFollow) { - created = true - - actorFollow = await ActorFollowModel.create({ - actorId: byActor.id, - targetActorId: targetActor.id, - url: activityId, - - state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL - ? 'pending' - : 'accepted' - }, { transaction: t }) - } + const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({ + byActor, + targetActor, + activityId, + state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL + ? 'pending' + : 'accepted', + transaction: t + }) // Set the follow as accepted if the remote actor follows a channel or account // Or if the instance automatically accepts followers -- cgit v1.2.3