aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/feeds/feeds.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-22 17:06:26 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-29 09:32:20 +0200
commit696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd (patch)
treee1b88451c4357add80721f530993e2b48d197feb /server/tests/feeds/feeds.ts
parent72c33e716fecd1826dcf645957f8669821f91ff3 (diff)
downloadPeerTube-696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd.tar.gz
PeerTube-696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd.tar.zst
PeerTube-696d83fd1377486dd03cc1bd02a21d9b6ddd9fcd.zip
Block comments from muted accounts/servers
Add better control for users of comments displayed on their videos: * Do not forward comments from muted remote accounts/servers (muted by the current server or by the video owner) * Do not list threads and hide replies (with their children) of accounts/servers muted by the video owner * Hide from RSS comments of muted accounts/servers by video owners Use case: * Try to limit spam propagation in the federation * Add ability for users to automatically hide comments on their videos from undesirable accounts/servers (the comment section belongs to videomakers, so they choose what's posted there)
Diffstat (limited to 'server/tests/feeds/feeds.ts')
-rw-r--r--server/tests/feeds/feeds.ts41
1 files changed, 35 insertions, 6 deletions
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 7fac921a3..ba961cdba 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -1,7 +1,14 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import * as libxmljs from 'libxmljs'
6import {
7 addAccountToAccountBlocklist,
8 addAccountToServerBlocklist,
9 removeAccountFromServerBlocklist
10} from '@shared/extra-utils/users/blocklist'
11import { VideoPrivacy } from '@shared/models'
5import { 12import {
6 cleanupTests, 13 cleanupTests,
7 createUser, 14 createUser,
@@ -13,14 +20,12 @@ import {
13 ServerInfo, 20 ServerInfo,
14 setAccessTokensToServers, 21 setAccessTokensToServers,
15 uploadVideo, 22 uploadVideo,
23 uploadVideoAndGetId,
16 userLogin 24 userLogin
17} from '../../../shared/extra-utils' 25} from '../../../shared/extra-utils'
18import * as libxmljs from 'libxmljs'
19import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
20import { waitJobs } from '../../../shared/extra-utils/server/jobs' 26import { waitJobs } from '../../../shared/extra-utils/server/jobs'
27import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
21import { User } from '../../../shared/models/users' 28import { User } from '../../../shared/models/users'
22import { VideoPrivacy } from '@shared/models'
23import { addAccountToServerBlocklist } from '@shared/extra-utils/users/blocklist'
24 29
25chai.use(require('chai-xml')) 30chai.use(require('chai-xml'))
26chai.use(require('chai-json-schema')) 31chai.use(require('chai-json-schema'))
@@ -219,7 +224,11 @@ describe('Test syndication feeds', () => {
219 }) 224 })
220 225
221 it('Should not list comments from muted accounts or instances', async function () { 226 it('Should not list comments from muted accounts or instances', async function () {
222 await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, 'root@localhost:' + servers[0].port) 227 this.timeout(30000)
228
229 const remoteHandle = 'root@localhost:' + servers[0].port
230
231 await addAccountToServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
223 232
224 { 233 {
225 const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 2 }) 234 const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 2 })
@@ -227,6 +236,26 @@ describe('Test syndication feeds', () => {
227 expect(jsonObj.items.length).to.be.equal(0) 236 expect(jsonObj.items.length).to.be.equal(0)
228 } 237 }
229 238
239 await removeAccountFromServerBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
240
241 {
242 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'server 2' })).uuid
243 await waitJobs(servers)
244 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'super comment')
245 await waitJobs(servers)
246
247 const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 3 })
248 const jsonObj = JSON.parse(json.text)
249 expect(jsonObj.items.length).to.be.equal(3)
250 }
251
252 await addAccountToAccountBlocklist(servers[1].url, servers[1].accessToken, remoteHandle)
253
254 {
255 const json = await getJSONfeed(servers[1].url, 'video-comments', { version: 4 })
256 const jsonObj = JSON.parse(json.text)
257 expect(jsonObj.items.length).to.be.equal(2)
258 }
230 }) 259 })
231 }) 260 })
232 261