+
+ {
+ const body = await commands[1].getAdminList({ filter: 'comment' })
+ expect(body.total).to.equal(0)
+ expect(body.data.length).to.equal(0)
+ }
+ })
+
+ it('Should report abuse on a remote comment', async function () {
+ this.timeout(10000)
+
+ const comment = await getComment(servers[0], servers[1].store.videoCreated.uuid)
+
+ const reason = 'it is a really bad comment'
+ await commands[0].report({ commentId: comment.id, reason })
+
+ await waitJobs(servers)
+ })
+
+ it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
+ const commentServer2 = await getComment(servers[0], servers[1].store.videoCreated.shortUUID)
+
+ {
+ const body = await commands[0].getAdminList({ filter: 'comment' })
+ expect(body.total).to.equal(2)
+ expect(body.data.length).to.equal(2)
+
+ const abuse = body.data[0]
+ expect(abuse.reason).to.equal('it is a bad comment')
+ expect(abuse.countReportsForReporter).to.equal(6)
+ expect(abuse.countReportsForReportee).to.equal(5)
+
+ const abuse2 = body.data[1]
+
+ expect(abuse2.reason).to.equal('it is a really bad comment')
+
+ expect(abuse2.reporterAccount.name).to.equal('root')
+ expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
+
+ expect(abuse2.video).to.be.null
+
+ expect(abuse2.comment.deleted).to.be.false
+ expect(abuse2.comment.id).to.equal(commentServer2.id)
+ expect(abuse2.comment.text).to.equal(commentServer2.text)
+ expect(abuse2.comment.video.name).to.equal('server 2')
+ expect(abuse2.comment.video.uuid).to.equal(servers[1].store.videoCreated.uuid)
+
+ expect(abuse2.state.id).to.equal(AbuseState.PENDING)
+ expect(abuse2.state.label).to.equal('Pending')
+
+ expect(abuse2.moderationComment).to.be.null
+
+ expect(abuse2.countReportsForReporter).to.equal(6)
+ expect(abuse2.countReportsForReportee).to.equal(2)
+ }
+
+ {
+ const body = await commands[1].getAdminList({ filter: 'comment' })
+ expect(body.total).to.equal(1)
+ expect(body.data.length).to.equal(1)
+
+ abuseServer2 = body.data[0]
+ expect(abuseServer2.reason).to.equal('it is a really bad comment')
+ expect(abuseServer2.reporterAccount.name).to.equal('root')
+ expect(abuseServer2.reporterAccount.host).to.equal(servers[0].host)
+
+ expect(abuseServer2.state.id).to.equal(AbuseState.PENDING)
+ expect(abuseServer2.state.label).to.equal('Pending')
+
+ expect(abuseServer2.moderationComment).to.be.null
+
+ expect(abuseServer2.countReportsForReporter).to.equal(1)
+ expect(abuseServer2.countReportsForReportee).to.equal(1)
+ }
+ })
+
+ it('Should keep the comment abuse when deleting the comment', async function () {
+ this.timeout(10000)
+
+ const commentServer2 = await getComment(servers[0], servers[1].store.videoCreated.uuid)
+
+ await servers[0].comments.delete({ videoId: servers[1].store.videoCreated.uuid, commentId: commentServer2.id })
+
+ await waitJobs(servers)
+
+ const body = await commands[0].getAdminList({ filter: 'comment' })
+ expect(body.total).to.equal(2)
+ expect(body.data).to.have.lengthOf(2)
+
+ const abuse = body.data.find(a => a.comment?.id === commentServer2.id)
+ expect(abuse).to.not.be.undefined
+
+ expect(abuse.comment.text).to.be.empty
+ expect(abuse.comment.video.name).to.equal('server 2')
+ expect(abuse.comment.deleted).to.be.true
+ })
+
+ it('Should delete the comment abuse', async function () {
+ this.timeout(10000)
+
+ await commands[1].delete({ abuseId: abuseServer2.id })
+
+ await waitJobs(servers)
+
+ {
+ const body = await commands[1].getAdminList({ filter: 'comment' })
+ expect(body.total).to.equal(0)
+ expect(body.data.length).to.equal(0)
+ }
+
+ {
+ const body = await commands[0].getAdminList({ filter: 'comment' })
+ expect(body.total).to.equal(2)
+ }
+ })
+
+ it('Should list and filter video abuses', async function () {
+ {
+ const body = await commands[0].getAdminList({ filter: 'comment', searchReportee: 'foo' })
+ expect(body.total).to.equal(0)
+ }
+
+ {
+ const body = await commands[0].getAdminList({ filter: 'comment', searchReportee: 'ot' })
+ expect(body.total).to.equal(2)
+ }
+
+ {
+ const body = await commands[0].getAdminList({ filter: 'comment', start: 1, count: 1, sort: 'createdAt' })
+ expect(body.data).to.have.lengthOf(1)
+ expect(body.data[0].comment.text).to.be.empty
+ }
+
+ {
+ const body = await commands[0].getAdminList({ filter: 'comment', start: 1, count: 1, sort: '-createdAt' })
+ expect(body.data).to.have.lengthOf(1)
+ expect(body.data[0].comment.text).to.equal('comment server 1')
+ }
+ })