Fix channel follow with manually approved follower
This commit is contained in:
parent
1593e0dd5c
commit
a6b26afc56
3 changed files with 668 additions and 619 deletions
|
@ -47,7 +47,7 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ
|
|||
byActor,
|
||||
targetActor,
|
||||
activityId,
|
||||
state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
|
||||
state: await isFollowingInstance(targetActor) && CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL
|
||||
? 'pending'
|
||||
: 'accepted',
|
||||
transaction: t
|
||||
|
@ -134,7 +134,7 @@ async function acceptIfNeeded (actorFollow: MActorFollow, targetActor: MActorFul
|
|||
// Or if the instance automatically accepts followers
|
||||
if (actorFollow.state === 'accepted') return
|
||||
if (!await isFollowingInstance(targetActor)) return
|
||||
if (CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === true) return
|
||||
if (CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === true && await isFollowingInstance(targetActor)) return
|
||||
|
||||
actorFollow.state = 'accepted'
|
||||
|
||||
|
|
|
@ -96,6 +96,8 @@ describe('Test follows moderation', function () {
|
|||
commands = servers.map(s => s.follows)
|
||||
})
|
||||
|
||||
describe('Default behaviour', function () {
|
||||
|
||||
it('Should have server 1 following server 2', async function () {
|
||||
this.timeout(30000)
|
||||
|
||||
|
@ -119,6 +121,9 @@ describe('Test follows moderation', function () {
|
|||
it('Should not not have follows anymore', async function () {
|
||||
await checkNoFollowers(servers)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Disabled/Enabled followers', function () {
|
||||
|
||||
it('Should disable followers on server 2', async function () {
|
||||
this.timeout(10000)
|
||||
|
@ -159,6 +164,9 @@ describe('Test follows moderation', function () {
|
|||
|
||||
await checkServer1And2HasFollowers(servers)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Manual approbation', function () {
|
||||
|
||||
it('Should manually approve followers', async function () {
|
||||
this.timeout(20000)
|
||||
|
@ -244,6 +252,20 @@ describe('Test follows moderation', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('Should still auto accept channel followers', async function () {
|
||||
await commands[0].follow({ handles: [ 'root_channel@' + servers[1].host ] })
|
||||
|
||||
await waitJobs(servers)
|
||||
|
||||
const body = await commands[0].getFollowings()
|
||||
const follow = body.data[0]
|
||||
expect(follow.following.name).to.equal('root_channel')
|
||||
expect(follow.state).to.equal('accepted')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Accept/reject state', function () {
|
||||
|
||||
it('Should not change the follow on refollow with and without auto accept', async function () {
|
||||
const run = async () => {
|
||||
await commands[0].follow({ hosts: [ servers[2].url ] })
|
||||
|
@ -314,6 +336,9 @@ describe('Test follows moderation', function () {
|
|||
followingState: 'accepted'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Muted servers', function () {
|
||||
|
||||
it('Should ignore follow requests of muted servers', async function () {
|
||||
await servers[1].blocklist.addToServerBlocklist({ server: servers[0].host })
|
||||
|
@ -339,6 +364,7 @@ describe('Test follows moderation', function () {
|
|||
followingState: 'deleted'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
await cleanupTests(servers)
|
||||
|
|
|
@ -53,6 +53,7 @@ describe('Test users subscriptions', function () {
|
|||
command = servers[0].subscriptions
|
||||
})
|
||||
|
||||
describe('Destinction between server videos and user videos', function () {
|
||||
it('Should display videos of server 2 on server 1', async function () {
|
||||
const { total } = await servers[0].videos.list()
|
||||
|
||||
|
@ -84,6 +85,9 @@ describe('Test users subscriptions', function () {
|
|||
expect(video.name).to.not.contain('video server 3 added after follow')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Subscription endpoints', function () {
|
||||
|
||||
it('Should list subscriptions', async function () {
|
||||
{
|
||||
|
@ -157,6 +161,9 @@ describe('Test users subscriptions', function () {
|
|||
expect(body.data).to.have.lengthOf(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Subscription videos', function () {
|
||||
|
||||
it('Should list subscription videos', async function () {
|
||||
{
|
||||
|
@ -221,7 +228,7 @@ describe('Test users subscriptions', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('Should have server 1 follow server 3 and display server 3 videos', async function () {
|
||||
it('Should have server 1 following server 3 and display server 3 videos', async function () {
|
||||
this.timeout(60000)
|
||||
|
||||
await servers[0].follows.follow({ hosts: [ servers[2].url ] })
|
||||
|
@ -277,6 +284,9 @@ describe('Test users subscriptions', function () {
|
|||
expect(videos[3].name).to.equal('video server 1 added after follow')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Existing subscription video update', function () {
|
||||
|
||||
it('Should update a video of server 3 and see the updated video on server 1', async function () {
|
||||
this.timeout(30000)
|
||||
|
@ -288,6 +298,9 @@ describe('Test users subscriptions', function () {
|
|||
const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' })
|
||||
expect(body.data[2].name).to.equal('video server 3 added after follow updated')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Subscription removal', function () {
|
||||
|
||||
it('Should remove user of server 3 subscription', async function () {
|
||||
this.timeout(30000)
|
||||
|
@ -335,6 +348,9 @@ describe('Test users subscriptions', function () {
|
|||
expect(video.name).to.not.contain('video server 3 added after follow updated')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Re-follow', function () {
|
||||
|
||||
it('Should follow user of server 3 again', async function () {
|
||||
this.timeout(60000)
|
||||
|
@ -378,6 +394,9 @@ describe('Test users subscriptions', function () {
|
|||
|
||||
await waitJobs(servers)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Followers listing', function () {
|
||||
|
||||
it('Should list user 3 followers', async function () {
|
||||
{
|
||||
|
@ -539,6 +558,9 @@ describe('Test users subscriptions', function () {
|
|||
expect(data[0].follower.name).to.equal('user1')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('Subscription videos privacy', function () {
|
||||
|
||||
it('Should update video as internal and not see from remote server', async function () {
|
||||
this.timeout(30000)
|
||||
|
@ -573,6 +595,7 @@ describe('Test users subscriptions', function () {
|
|||
expect(data.find(v => v.name === 'private')).to.not.exist
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
await cleanupTests(servers)
|
||||
|
|
Loading…
Reference in a new issue