aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-13 16:18:42 +0200
committerChocobozzz <me@florianbigard.com>2021-10-13 16:18:42 +0200
commit1cf0df024e58432da39fe2d1b317fb5c9ab8bd2e (patch)
treea9e3e6e3330552fddda81688dd7ce69e099f0b05 /server/lib/activitypub
parentf87d82b93d474d1290b3c641e63a39197193cb7e (diff)
downloadPeerTube-1cf0df024e58432da39fe2d1b317fb5c9ab8bd2e.tar.gz
PeerTube-1cf0df024e58432da39fe2d1b317fb5c9ab8bd2e.tar.zst
PeerTube-1cf0df024e58432da39fe2d1b317fb5c9ab8bd2e.zip
Fix actor follow counts calculation
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/process/process-follow.ts19
1 files changed, 10 insertions, 9 deletions
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
48 return { actorFollow: undefined as MActorFollowActors } 48 return { actorFollow: undefined as MActorFollowActors }
49 } 49 }
50 50
51 const [ actorFollow, created ] = await ActorFollowModel.findOrCreate<MActorFollowActors>({ 51 // Don't use findOrCreate by sequelize that breaks our actor follow hooks
52 where: { 52 let created = false
53 actorId: byActor.id, 53 let actorFollow: MActorFollowActors = await ActorFollowModel.loadByActorAndTarget(byActor.id, targetActor.id, t)
54 targetActorId: targetActor.id 54
55 }, 55 if (!actorFollow) {
56 defaults: { 56 created = true
57
58 actorFollow = await ActorFollowModel.create({
57 actorId: byActor.id, 59 actorId: byActor.id,
58 targetActorId: targetActor.id, 60 targetActorId: targetActor.id,
59 url: activityId, 61 url: activityId,
@@ -61,9 +63,8 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ
61 state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL 63 state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
62 ? 'pending' 64 ? 'pending'
63 : 'accepted' 65 : 'accepted'
64 }, 66 }, { transaction: t })
65 transaction: t 67 }
66 })
67 68
68 // Set the follow as accepted if the remote actor follows a channel or account 69 // Set the follow as accepted if the remote actor follows a channel or account
69 // Or if the instance automatically accepts followers 70 // Or if the instance automatically accepts followers