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/job-queue/handlers/activitypub-follow.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'server/lib/job-queue/handlers') diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index 91e3d33c6..55a15930a 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts @@ -54,21 +54,13 @@ async function follow (fromActor: MActor, targetActor: MActorFull, isAutoFollow const state = !fromActor.serverId && !targetActor.serverId ? 'accepted' : 'pending' const actorFollow = await sequelizeTypescript.transaction(async t => { - const [ actorFollow ] = await ActorFollowModel.findOrCreate({ - where: { - actorId: fromActor.id, - targetActorId: targetActor.id - }, - defaults: { - state, - url: getLocalActorFollowActivityPubUrl(fromActor, targetActor), - actorId: fromActor.id, - targetActorId: targetActor.id - }, + const [ actorFollow ] = await ActorFollowModel.findOrCreateCustom({ + byActor: fromActor, + state, + targetActor, + activityId: getLocalActorFollowActivityPubUrl(fromActor, targetActor), transaction: t }) - actorFollow.ActorFollowing = targetActor - actorFollow.ActorFollower = fromActor // Send a notification to remote server if our follow is not already accepted if (actorFollow.state !== 'accepted') sendFollow(actorFollow, t) -- cgit v1.2.3