/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import * as chai from 'chai'
import 'mocha'
+import * as chai from 'chai'
+import * as libxmljs from 'libxmljs'
+import {
+ addAccountToAccountBlocklist,
+ addAccountToServerBlocklist,
+ removeAccountFromServerBlocklist
+} from '@shared/extra-utils/users/blocklist'
+import { VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createUser,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
+ uploadVideoAndGetId,
userLogin
} from '../../../shared/extra-utils'
-import * as libxmljs from 'libxmljs'
-import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
+import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
import { User } from '../../../shared/models/users'
chai.use(require('chai-xml'))
await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 2')
}
+ {
+ const videoAttributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED }
+ const res = await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
+ const videoId = res.body.video.id
+
+ await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'comment on unlisted video')
+ }
+
await waitJobs(servers)
})
})
describe('Video comments feed', function () {
- it('Should contain valid comments (covers JSON feed 1.0 endpoint)', async function () {
+
+ it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () {
for (const server of servers) {
const json = await getJSONfeed(server.url, 'video-comments')
expect(jsonObj.items[1].html_content).to.equal('super comment 1')
}
})
+
+ it('Should not list comments from muted accounts or instances', async function () {
+ this.timeout(30000)
+
+ const remoteHandle = 'root@localhost:' + servers[0].port
+
+ await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
+
+ {
+ const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 2 })
+ const jsonObj = JSON.parse(json.text)
+ expect(jsonObj.items.length).to.be.equal(0)
+ }
+
+ await removeAccountFromServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
+
+ {
+ const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })).uuid
+ await waitJobs(servers)
+ await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'super comment')
+ await waitJobs(servers)
+
+ const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 3 })
+ const jsonObj = JSON.parse(json.text)
+ expect(jsonObj.items.length).to.be.equal(3)
+ }
+
+ await addAccountToAccountBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
+
+ {
+ const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 4 })
+ const jsonObj = JSON.parse(json.text)
+ expect(jsonObj.items.length).to.be.equal(2)
+ }
+ })
})
after(async function () {