diff options
Diffstat (limited to 'server/models/activitypub/actor-follow.ts')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index c65b975d2..f21d2b8a2 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -36,6 +36,7 @@ import { | |||
36 | MActorFollowSubscriptions | 36 | MActorFollowSubscriptions |
37 | } from '@server/typings/models' | 37 | } from '@server/typings/models' |
38 | import { ActivityPubActorType } from '@shared/models' | 38 | import { ActivityPubActorType } from '@shared/models' |
39 | import { afterCommitIfTransaction } from '@server/helpers/database-utils' | ||
39 | 40 | ||
40 | @Table({ | 41 | @Table({ |
41 | tableName: 'actorFollow', | 42 | tableName: 'actorFollow', |
@@ -104,20 +105,20 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
104 | 105 | ||
105 | @AfterCreate | 106 | @AfterCreate |
106 | @AfterUpdate | 107 | @AfterUpdate |
107 | static incrementFollowerAndFollowingCount (instance: ActorFollowModel) { | 108 | static incrementFollowerAndFollowingCount (instance: ActorFollowModel, options: any) { |
108 | if (instance.state !== 'accepted') return undefined | 109 | if (instance.state !== 'accepted') return undefined |
109 | 110 | ||
110 | return Promise.all([ | 111 | return Promise.all([ |
111 | ActorModel.incrementFollows(instance.actorId, 'followingCount', 1), | 112 | ActorModel.rebuildFollowsCount(instance.actorId, 'following', options.transaction), |
112 | ActorModel.incrementFollows(instance.targetActorId, 'followersCount', 1) | 113 | ActorModel.rebuildFollowsCount(instance.targetActorId, 'followers', options.transaction) |
113 | ]) | 114 | ]) |
114 | } | 115 | } |
115 | 116 | ||
116 | @AfterDestroy | 117 | @AfterDestroy |
117 | static decrementFollowerAndFollowingCount (instance: ActorFollowModel) { | 118 | static decrementFollowerAndFollowingCount (instance: ActorFollowModel, options: any) { |
118 | return Promise.all([ | 119 | return Promise.all([ |
119 | ActorModel.incrementFollows(instance.actorId, 'followingCount',-1), | 120 | ActorModel.rebuildFollowsCount(instance.actorId, 'following', options.transaction), |
120 | ActorModel.incrementFollows(instance.targetActorId, 'followersCount', -1) | 121 | ActorModel.rebuildFollowsCount(instance.targetActorId, 'followers', options.transaction) |
121 | ]) | 122 | ]) |
122 | } | 123 | } |
123 | 124 | ||