aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/migrations/0175-actor-follow-counts.ts1
-rw-r--r--server/models/activitypub/actor-follow.ts7
-rw-r--r--server/tests/api/server/follows.ts6
3 files changed, 6 insertions, 8 deletions
diff --git a/server/initializers/migrations/0175-actor-follow-counts.ts b/server/initializers/migrations/0175-actor-follow-counts.ts
index 06ef77b49..4fb524181 100644
--- a/server/initializers/migrations/0175-actor-follow-counts.ts
+++ b/server/initializers/migrations/0175-actor-follow-counts.ts
@@ -1,5 +1,4 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { ACTOR_FOLLOW_SCORE } from '../index'
3 2
4async function up (utils: { 3async function up (utils: {
5 transaction: Sequelize.Transaction, 4 transaction: Sequelize.Transaction,
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 435d22db5..ced481547 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -2,9 +2,8 @@ import * as Bluebird from 'bluebird'
2import { values } from 'lodash' 2import { values } from 'lodash'
3import * as Sequelize from 'sequelize' 3import * as Sequelize from 'sequelize'
4import { 4import {
5 AfterCreate, AfterDestroy, AfterUpdate, 5 AfterCreate, AfterDestroy, AfterUpdate, AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, IsInt, Max, Model,
6 AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, IsInt, Max, Model, Table, 6 Table, UpdatedAt
7 UpdatedAt
8} from 'sequelize-typescript' 7} from 'sequelize-typescript'
9import { FollowState } from '../../../shared/models/actors' 8import { FollowState } from '../../../shared/models/actors'
10import { AccountFollow } from '../../../shared/models/actors/follow.model' 9import { AccountFollow } from '../../../shared/models/actors/follow.model'
@@ -83,7 +82,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
83 @AfterCreate 82 @AfterCreate
84 @AfterUpdate 83 @AfterUpdate
85 static incrementFollowerAndFollowingCount (instance: ActorFollowModel) { 84 static incrementFollowerAndFollowingCount (instance: ActorFollowModel) {
86 if (instance.state !== 'accepted') return 85 if (instance.state !== 'accepted') return undefined
87 86
88 return Promise.all([ 87 return Promise.all([
89 ActorModel.incrementFollows(instance.actorId, 'followingCount', 1), 88 ActorModel.incrementFollows(instance.actorId, 'followingCount', 1),
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 27cf94985..d16e98bc1 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -117,7 +117,7 @@ describe('Test follows', function () {
117 expect(follows.length).to.equal(0) 117 expect(follows.length).to.equal(0)
118 }) 118 })
119 119
120 it('Should have the correct following counts', async function () { 120 it('Should have the correct follows counts', async function () {
121 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) 121 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2)
122 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) 122 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
123 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) 123 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0)
@@ -158,7 +158,7 @@ describe('Test follows', function () {
158 expect(follows.length).to.equal(0) 158 expect(follows.length).to.equal(0)
159 }) 159 })
160 160
161 it('Should have the correct following counts 2', async function () { 161 it('Should have the correct follows counts 2', async function () {
162 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1) 162 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1)
163 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) 163 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
164 164
@@ -248,7 +248,7 @@ describe('Test follows', function () {
248 await wait(7000) 248 await wait(7000)
249 }) 249 })
250 250
251 it('Should have the correct following counts 2', async function () { 251 it('Should have the correct follows counts 3', async function () {
252 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) 252 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2)
253 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) 253 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0)
254 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) 254 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0)