From 1cf0df024e58432da39fe2d1b317fb5c9ab8bd2e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Oct 2021 16:18:42 +0200 Subject: Fix actor follow counts calculation --- server/lib/activitypub/process/process-follow.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index f85238f8e..5562f0798 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts @@ -48,12 +48,14 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ return { actorFollow: undefined as MActorFollowActors } } - const [ actorFollow, created ] = await ActorFollowModel.findOrCreate({ - where: { - actorId: byActor.id, - targetActorId: targetActor.id - }, - defaults: { + // 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, @@ -61,9 +63,8 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL ? 'pending' : 'accepted' - }, - transaction: t - }) + }, { 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