aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/moderation
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/moderation')
-rw-r--r--server/tests/api/moderation/abuses.ts96
-rw-r--r--server/tests/api/moderation/blocklist-notification.ts46
-rw-r--r--server/tests/api/moderation/blocklist.ts76
-rw-r--r--server/tests/api/moderation/video-blacklist.ts58
4 files changed, 138 insertions, 138 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 7574b8f4a..97a0d95c4 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -33,7 +33,7 @@ describe('Test abuses', function () {
33 // Server 1 and server 2 follow each other 33 // Server 1 and server 2 follow each other
34 await doubleFollow(servers[0], servers[1]) 34 await doubleFollow(servers[0], servers[1])
35 35
36 commands = servers.map(s => s.abusesCommand) 36 commands = servers.map(s => s.abuses)
37 }) 37 })
38 38
39 describe('Video abuses', function () { 39 describe('Video abuses', function () {
@@ -47,7 +47,7 @@ describe('Test abuses', function () {
47 name: 'my super name for server 1', 47 name: 'my super name for server 1',
48 description: 'my super description for server 1' 48 description: 'my super description for server 1'
49 } 49 }
50 await servers[0].videosCommand.upload({ attributes }) 50 await servers[0].videos.upload({ attributes })
51 } 51 }
52 52
53 { 53 {
@@ -55,17 +55,17 @@ describe('Test abuses', function () {
55 name: 'my super name for server 2', 55 name: 'my super name for server 2',
56 description: 'my super description for server 2' 56 description: 'my super description for server 2'
57 } 57 }
58 await servers[1].videosCommand.upload({ attributes }) 58 await servers[1].videos.upload({ attributes })
59 } 59 }
60 60
61 // Wait videos propagation, server 2 has transcoding enabled 61 // Wait videos propagation, server 2 has transcoding enabled
62 await waitJobs(servers) 62 await waitJobs(servers)
63 63
64 const { data } = await servers[0].videosCommand.list() 64 const { data } = await servers[0].videos.list()
65 expect(data.length).to.equal(2) 65 expect(data.length).to.equal(2)
66 66
67 servers[0].video = data.find(video => video.name === 'my super name for server 1') 67 servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
68 servers[1].video = data.find(video => video.name === 'my super name for server 2') 68 servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
69 }) 69 })
70 70
71 it('Should not have abuses', async function () { 71 it('Should not have abuses', async function () {
@@ -80,7 +80,7 @@ describe('Test abuses', function () {
80 this.timeout(15000) 80 this.timeout(15000)
81 81
82 const reason = 'my super bad reason' 82 const reason = 'my super bad reason'
83 await commands[0].report({ videoId: servers[0].video.id, reason }) 83 await commands[0].report({ videoId: servers[0].store.video.id, reason })
84 84
85 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2 85 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
86 await waitJobs(servers) 86 await waitJobs(servers)
@@ -100,7 +100,7 @@ describe('Test abuses', function () {
100 expect(abuse.reporterAccount.name).to.equal('root') 100 expect(abuse.reporterAccount.name).to.equal('root')
101 expect(abuse.reporterAccount.host).to.equal(servers[0].host) 101 expect(abuse.reporterAccount.host).to.equal(servers[0].host)
102 102
103 expect(abuse.video.id).to.equal(servers[0].video.id) 103 expect(abuse.video.id).to.equal(servers[0].store.video.id)
104 expect(abuse.video.channel).to.exist 104 expect(abuse.video.channel).to.exist
105 105
106 expect(abuse.comment).to.be.null 106 expect(abuse.comment).to.be.null
@@ -127,7 +127,7 @@ describe('Test abuses', function () {
127 this.timeout(10000) 127 this.timeout(10000)
128 128
129 const reason = 'my super bad reason 2' 129 const reason = 'my super bad reason 2'
130 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid }) 130 const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
131 await commands[0].report({ videoId, reason }) 131 await commands[0].report({ videoId, reason })
132 132
133 // We wait requests propagation 133 // We wait requests propagation
@@ -146,7 +146,7 @@ describe('Test abuses', function () {
146 expect(abuse1.reporterAccount.name).to.equal('root') 146 expect(abuse1.reporterAccount.name).to.equal('root')
147 expect(abuse1.reporterAccount.host).to.equal(servers[0].host) 147 expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
148 148
149 expect(abuse1.video.id).to.equal(servers[0].video.id) 149 expect(abuse1.video.id).to.equal(servers[0].store.video.id)
150 expect(abuse1.video.countReports).to.equal(1) 150 expect(abuse1.video.countReports).to.equal(1)
151 expect(abuse1.video.nthReport).to.equal(1) 151 expect(abuse1.video.nthReport).to.equal(1)
152 152
@@ -165,7 +165,7 @@ describe('Test abuses', function () {
165 expect(abuse2.reporterAccount.name).to.equal('root') 165 expect(abuse2.reporterAccount.name).to.equal('root')
166 expect(abuse2.reporterAccount.host).to.equal(servers[0].host) 166 expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
167 167
168 expect(abuse2.video.id).to.equal(servers[1].video.id) 168 expect(abuse2.video.id).to.equal(servers[1].store.video.id)
169 169
170 expect(abuse2.comment).to.be.null 170 expect(abuse2.comment).to.be.null
171 171
@@ -200,7 +200,7 @@ describe('Test abuses', function () {
200 this.timeout(10000) 200 this.timeout(10000)
201 201
202 { 202 {
203 const videoId = await servers[1].videosCommand.getId({ uuid: servers[0].video.uuid }) 203 const videoId = await servers[1].videos.getId({ uuid: servers[0].store.video.uuid })
204 await commands[1].report({ videoId, reason: 'will mute this' }) 204 await commands[1].report({ videoId, reason: 'will mute this' })
205 await waitJobs(servers) 205 await waitJobs(servers)
206 206
@@ -211,7 +211,7 @@ describe('Test abuses', function () {
211 const accountToBlock = 'root@' + servers[1].host 211 const accountToBlock = 'root@' + servers[1].host
212 212
213 { 213 {
214 await servers[0].blocklistCommand.addToServerBlocklist({ account: accountToBlock }) 214 await servers[0].blocklist.addToServerBlocklist({ account: accountToBlock })
215 215
216 const body = await commands[0].getAdminList() 216 const body = await commands[0].getAdminList()
217 expect(body.total).to.equal(2) 217 expect(body.total).to.equal(2)
@@ -221,7 +221,7 @@ describe('Test abuses', function () {
221 } 221 }
222 222
223 { 223 {
224 await servers[0].blocklistCommand.removeFromServerBlocklist({ account: accountToBlock }) 224 await servers[0].blocklist.removeFromServerBlocklist({ account: accountToBlock })
225 225
226 const body = await commands[0].getAdminList() 226 const body = await commands[0].getAdminList()
227 expect(body.total).to.equal(3) 227 expect(body.total).to.equal(3)
@@ -232,7 +232,7 @@ describe('Test abuses', function () {
232 const serverToBlock = servers[1].host 232 const serverToBlock = servers[1].host
233 233
234 { 234 {
235 await servers[0].blocklistCommand.addToServerBlocklist({ server: serverToBlock }) 235 await servers[0].blocklist.addToServerBlocklist({ server: serverToBlock })
236 236
237 const body = await commands[0].getAdminList() 237 const body = await commands[0].getAdminList()
238 expect(body.total).to.equal(2) 238 expect(body.total).to.equal(2)
@@ -242,7 +242,7 @@ describe('Test abuses', function () {
242 } 242 }
243 243
244 { 244 {
245 await servers[0].blocklistCommand.removeFromServerBlocklist({ server: serverToBlock }) 245 await servers[0].blocklist.removeFromServerBlocklist({ server: serverToBlock })
246 246
247 const body = await commands[0].getAdminList() 247 const body = await commands[0].getAdminList()
248 expect(body.total).to.equal(3) 248 expect(body.total).to.equal(3)
@@ -252,7 +252,7 @@ describe('Test abuses', function () {
252 it('Should keep the video abuse when deleting the video', async function () { 252 it('Should keep the video abuse when deleting the video', async function () {
253 this.timeout(10000) 253 this.timeout(10000)
254 254
255 await servers[1].videosCommand.remove({ id: abuseServer2.video.uuid }) 255 await servers[1].videos.remove({ id: abuseServer2.video.uuid })
256 256
257 await waitJobs(servers) 257 await waitJobs(servers)
258 258
@@ -272,15 +272,15 @@ describe('Test abuses', function () {
272 272
273 // register a second user to have two reporters/reportees 273 // register a second user to have two reporters/reportees
274 const user = { username: 'user2', password: 'password' } 274 const user = { username: 'user2', password: 'password' }
275 await servers[0].usersCommand.create({ ...user }) 275 await servers[0].users.create({ ...user })
276 const userAccessToken = await servers[0].loginCommand.getAccessToken(user) 276 const userAccessToken = await servers[0].login.getAccessToken(user)
277 277
278 // upload a third video via this user 278 // upload a third video via this user
279 const attributes = { 279 const attributes = {
280 name: 'my second super name for server 1', 280 name: 'my second super name for server 1',
281 description: 'my second super description for server 1' 281 description: 'my second super description for server 1'
282 } 282 }
283 const { id } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 283 const { id } = await servers[0].videos.upload({ token: userAccessToken, attributes })
284 const video3Id = id 284 const video3Id = id
285 285
286 // resume with the test 286 // resume with the test
@@ -288,7 +288,7 @@ describe('Test abuses', function () {
288 await commands[0].report({ videoId: video3Id, reason: reason3 }) 288 await commands[0].report({ videoId: video3Id, reason: reason3 })
289 289
290 const reason4 = 'my super bad reason 4' 290 const reason4 = 'my super bad reason 4'
291 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: reason4 }) 291 await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: reason4 })
292 292
293 { 293 {
294 const body = await commands[0].getAdminList() 294 const body = await commands[0].getAdminList()
@@ -301,7 +301,7 @@ describe('Test abuses', function () {
301 expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse") 301 expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
302 expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse") 302 expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
303 303
304 const abuseServer1 = abuses.find(a => a.video.id === servers[0].video.id) 304 const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.video.id)
305 expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") 305 expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
306 } 306 }
307 }) 307 })
@@ -312,7 +312,7 @@ describe('Test abuses', function () {
312 const reason5 = 'my super bad reason 5' 312 const reason5 = 'my super bad reason 5'
313 const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ] 313 const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
314 const createRes = await commands[0].report({ 314 const createRes = await commands[0].report({
315 videoId: servers[0].video.id, 315 videoId: servers[0].store.video.id,
316 reason: reason5, 316 reason: reason5,
317 predefinedReasons: predefinedReasons5, 317 predefinedReasons: predefinedReasons5,
318 startAt: 1, 318 startAt: 1,
@@ -391,10 +391,10 @@ describe('Test abuses', function () {
391 391
392 async function getComment (server: ServerInfo, videoIdArg: number | string) { 392 async function getComment (server: ServerInfo, videoIdArg: number | string) {
393 const videoId = typeof videoIdArg === 'string' 393 const videoId = typeof videoIdArg === 'string'
394 ? await server.videosCommand.getId({ uuid: videoIdArg }) 394 ? await server.videos.getId({ uuid: videoIdArg })
395 : videoIdArg 395 : videoIdArg
396 396
397 const { data } = await server.commentsCommand.listThreads({ videoId }) 397 const { data } = await server.comments.listThreads({ videoId })
398 398
399 return data[0] 399 return data[0]
400 } 400 }
@@ -402,11 +402,11 @@ describe('Test abuses', function () {
402 before(async function () { 402 before(async function () {
403 this.timeout(50000) 403 this.timeout(50000)
404 404
405 servers[0].video = await await servers[0].videosCommand.quickUpload({ name: 'server 1' }) 405 servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
406 servers[1].video = await await servers[1].videosCommand.quickUpload({ name: 'server 2' }) 406 servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
407 407
408 await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' }) 408 await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
409 await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' }) 409 await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
410 410
411 await waitJobs(servers) 411 await waitJobs(servers)
412 }) 412 })
@@ -414,7 +414,7 @@ describe('Test abuses', function () {
414 it('Should report abuse on a comment', async function () { 414 it('Should report abuse on a comment', async function () {
415 this.timeout(15000) 415 this.timeout(15000)
416 416
417 const comment = await getComment(servers[0], servers[0].video.id) 417 const comment = await getComment(servers[0], servers[0].store.video.id)
418 418
419 const reason = 'it is a bad comment' 419 const reason = 'it is a bad comment'
420 await commands[0].report({ commentId: comment.id, reason }) 420 await commands[0].report({ commentId: comment.id, reason })
@@ -424,7 +424,7 @@ describe('Test abuses', function () {
424 424
425 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () { 425 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () {
426 { 426 {
427 const comment = await getComment(servers[0], servers[0].video.id) 427 const comment = await getComment(servers[0], servers[0].store.video.id)
428 const body = await commands[0].getAdminList({ filter: 'comment' }) 428 const body = await commands[0].getAdminList({ filter: 'comment' })
429 429
430 expect(body.total).to.equal(1) 430 expect(body.total).to.equal(1)
@@ -442,8 +442,8 @@ describe('Test abuses', function () {
442 expect(abuse.comment.id).to.equal(comment.id) 442 expect(abuse.comment.id).to.equal(comment.id)
443 expect(abuse.comment.text).to.equal(comment.text) 443 expect(abuse.comment.text).to.equal(comment.text)
444 expect(abuse.comment.video.name).to.equal('server 1') 444 expect(abuse.comment.video.name).to.equal('server 1')
445 expect(abuse.comment.video.id).to.equal(servers[0].video.id) 445 expect(abuse.comment.video.id).to.equal(servers[0].store.video.id)
446 expect(abuse.comment.video.uuid).to.equal(servers[0].video.uuid) 446 expect(abuse.comment.video.uuid).to.equal(servers[0].store.video.uuid)
447 447
448 expect(abuse.countReportsForReporter).to.equal(5) 448 expect(abuse.countReportsForReporter).to.equal(5)
449 expect(abuse.countReportsForReportee).to.equal(5) 449 expect(abuse.countReportsForReportee).to.equal(5)
@@ -459,7 +459,7 @@ describe('Test abuses', function () {
459 it('Should report abuse on a remote comment', async function () { 459 it('Should report abuse on a remote comment', async function () {
460 this.timeout(10000) 460 this.timeout(10000)
461 461
462 const comment = await getComment(servers[0], servers[1].video.uuid) 462 const comment = await getComment(servers[0], servers[1].store.video.uuid)
463 463
464 const reason = 'it is a really bad comment' 464 const reason = 'it is a really bad comment'
465 await commands[0].report({ commentId: comment.id, reason }) 465 await commands[0].report({ commentId: comment.id, reason })
@@ -468,7 +468,7 @@ describe('Test abuses', function () {
468 }) 468 })
469 469
470 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () { 470 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
471 const commentServer2 = await getComment(servers[0], servers[1].video.id) 471 const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
472 472
473 { 473 {
474 const body = await commands[0].getAdminList({ filter: 'comment' }) 474 const body = await commands[0].getAdminList({ filter: 'comment' })
@@ -493,7 +493,7 @@ describe('Test abuses', function () {
493 expect(abuse2.comment.id).to.equal(commentServer2.id) 493 expect(abuse2.comment.id).to.equal(commentServer2.id)
494 expect(abuse2.comment.text).to.equal(commentServer2.text) 494 expect(abuse2.comment.text).to.equal(commentServer2.text)
495 expect(abuse2.comment.video.name).to.equal('server 2') 495 expect(abuse2.comment.video.name).to.equal('server 2')
496 expect(abuse2.comment.video.uuid).to.equal(servers[1].video.uuid) 496 expect(abuse2.comment.video.uuid).to.equal(servers[1].store.video.uuid)
497 497
498 expect(abuse2.state.id).to.equal(AbuseState.PENDING) 498 expect(abuse2.state.id).to.equal(AbuseState.PENDING)
499 expect(abuse2.state.label).to.equal('Pending') 499 expect(abuse2.state.label).to.equal('Pending')
@@ -527,9 +527,9 @@ describe('Test abuses', function () {
527 it('Should keep the comment abuse when deleting the comment', async function () { 527 it('Should keep the comment abuse when deleting the comment', async function () {
528 this.timeout(10000) 528 this.timeout(10000)
529 529
530 const commentServer2 = await getComment(servers[0], servers[1].video.id) 530 const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
531 531
532 await servers[0].commentsCommand.delete({ videoId: servers[1].video.uuid, commentId: commentServer2.id }) 532 await servers[0].comments.delete({ videoId: servers[1].store.video.uuid, commentId: commentServer2.id })
533 533
534 await waitJobs(servers) 534 await waitJobs(servers)
535 535
@@ -592,16 +592,16 @@ describe('Test abuses', function () {
592 describe('Account abuses', function () { 592 describe('Account abuses', function () {
593 593
594 function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) { 594 function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
595 return server.accountsCommand.get({ accountName: targetName + '@' + targetServer.host }) 595 return server.accounts.get({ accountName: targetName + '@' + targetServer.host })
596 } 596 }
597 597
598 before(async function () { 598 before(async function () {
599 this.timeout(50000) 599 this.timeout(50000)
600 600
601 await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' }) 601 await servers[0].users.create({ username: 'user_1', password: 'donald' })
602 602
603 const token = await servers[1].usersCommand.generateUserAndToken('user_2') 603 const token = await servers[1].users.generateUserAndToken('user_2')
604 await servers[1].videosCommand.upload({ token, attributes: { name: 'super video' } }) 604 await servers[1].videos.upload({ token, attributes: { name: 'super video' } })
605 605
606 await waitJobs(servers) 606 await waitJobs(servers)
607 }) 607 })
@@ -702,7 +702,7 @@ describe('Test abuses', function () {
702 this.timeout(10000) 702 this.timeout(10000)
703 703
704 const account = await getAccountFromServer(servers[1], 'user_2', servers[1]) 704 const account = await getAccountFromServer(servers[1], 'user_2', servers[1])
705 await servers[1].usersCommand.remove({ userId: account.userId }) 705 await servers[1].users.remove({ userId: account.userId })
706 706
707 await waitJobs(servers) 707 await waitJobs(servers)
708 708
@@ -759,11 +759,11 @@ describe('Test abuses', function () {
759 let userAccessToken: string 759 let userAccessToken: string
760 760
761 before(async function () { 761 before(async function () {
762 userAccessToken = await servers[0].usersCommand.generateUserAndToken('user_42') 762 userAccessToken = await servers[0].users.generateUserAndToken('user_42')
763 763
764 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' }) 764 await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: 'user reason 1' })
765 765
766 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid }) 766 const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' }) 767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' })
768 }) 768 })
769 769
@@ -830,9 +830,9 @@ describe('Test abuses', function () {
830 let abuseMessageModerationId: number 830 let abuseMessageModerationId: number
831 831
832 before(async function () { 832 before(async function () {
833 userToken = await servers[0].usersCommand.generateUserAndToken('user_43') 833 userToken = await servers[0].users.generateUserAndToken('user_43')
834 834
835 const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' }) 835 const body = await commands[0].report({ token: userToken, videoId: servers[0].store.video.id, reason: 'user 43 reason 1' })
836 abuseId = body.abuse.id 836 abuseId = body.abuse.id
837 }) 837 })
838 838
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts
index 92a0ec681..6b56fdd65 100644
--- a/server/tests/api/moderation/blocklist-notification.ts
+++ b/server/tests/api/moderation/blocklist-notification.ts
@@ -8,7 +8,7 @@ import { UserNotificationType } from '@shared/models'
8const expect = chai.expect 8const expect = chai.expect
9 9
10async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) { 10async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) {
11 const { data } = await server.notificationsCommand.list({ token, start: 0, count: 10, unread: true }) 11 const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true })
12 expect(data).to.have.lengthOf(expected.length) 12 expect(data).to.have.lengthOf(expected.length)
13 13
14 for (const type of expected) { 14 for (const type of expected) {
@@ -26,24 +26,24 @@ describe('Test blocklist', function () {
26 26
27 async function resetState () { 27 async function resetState () {
28 try { 28 try {
29 await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host }) 29 await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
30 await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host }) 30 await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
31 } catch {} 31 } catch {}
32 32
33 await waitJobs(servers) 33 await waitJobs(servers)
34 34
35 await servers[0].notificationsCommand.markAsReadAll({ token: userToken1 }) 35 await servers[0].notifications.markAsReadAll({ token: userToken1 })
36 await servers[0].notificationsCommand.markAsReadAll({ token: userToken2 }) 36 await servers[0].notifications.markAsReadAll({ token: userToken2 })
37 37
38 { 38 {
39 const { uuid } = await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video' } }) 39 const { uuid } = await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video' } })
40 videoUUID = uuid 40 videoUUID = uuid
41 41
42 await waitJobs(servers) 42 await waitJobs(servers)
43 } 43 }
44 44
45 { 45 {
46 await servers[1].commentsCommand.createThread({ 46 await servers[1].comments.createThread({
47 token: remoteUserToken, 47 token: remoteUserToken,
48 videoId: videoUUID, 48 videoId: videoUUID,
49 text: '@user2@' + servers[0].host + ' hello' 49 text: '@user2@' + servers[0].host + ' hello'
@@ -52,8 +52,8 @@ describe('Test blocklist', function () {
52 52
53 { 53 {
54 54
55 await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host }) 55 await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
56 await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host }) 56 await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
57 } 57 }
58 58
59 await waitJobs(servers) 59 await waitJobs(servers)
@@ -67,29 +67,29 @@ describe('Test blocklist', function () {
67 67
68 { 68 {
69 const user = { username: 'user1', password: 'password' } 69 const user = { username: 'user1', password: 'password' }
70 await servers[0].usersCommand.create({ 70 await servers[0].users.create({
71 username: user.username, 71 username: user.username,
72 password: user.password, 72 password: user.password,
73 videoQuota: -1, 73 videoQuota: -1,
74 videoQuotaDaily: -1 74 videoQuotaDaily: -1
75 }) 75 })
76 76
77 userToken1 = await servers[0].loginCommand.getAccessToken(user) 77 userToken1 = await servers[0].login.getAccessToken(user)
78 await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } }) 78 await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
79 } 79 }
80 80
81 { 81 {
82 const user = { username: 'user2', password: 'password' } 82 const user = { username: 'user2', password: 'password' }
83 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 83 await servers[0].users.create({ username: user.username, password: user.password })
84 84
85 userToken2 = await servers[0].loginCommand.getAccessToken(user) 85 userToken2 = await servers[0].login.getAccessToken(user)
86 } 86 }
87 87
88 { 88 {
89 const user = { username: 'user3', password: 'password' } 89 const user = { username: 'user3', password: 'password' }
90 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 90 await servers[1].users.create({ username: user.username, password: user.password })
91 91
92 remoteUserToken = await servers[1].loginCommand.getAccessToken(user) 92 remoteUserToken = await servers[1].login.getAccessToken(user)
93 } 93 }
94 94
95 await doubleFollow(servers[0], servers[1]) 95 await doubleFollow(servers[0], servers[1])
@@ -111,7 +111,7 @@ describe('Test blocklist', function () {
111 it('Should block an account', async function () { 111 it('Should block an account', async function () {
112 this.timeout(10000) 112 this.timeout(10000)
113 113
114 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }) 114 await servers[0].blocklist.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
115 await waitJobs(servers) 115 await waitJobs(servers)
116 }) 116 })
117 117
@@ -124,7 +124,7 @@ describe('Test blocklist', function () {
124 124
125 await checkNotifications(servers[0], userToken2, notifs) 125 await checkNotifications(servers[0], userToken2, notifs)
126 126
127 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }) 127 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
128 }) 128 })
129 }) 129 })
130 130
@@ -144,7 +144,7 @@ describe('Test blocklist', function () {
144 it('Should block an account', async function () { 144 it('Should block an account', async function () {
145 this.timeout(10000) 145 this.timeout(10000)
146 146
147 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, server: servers[1].host }) 147 await servers[0].blocklist.addToMyBlocklist({ token: userToken1, server: servers[1].host })
148 await waitJobs(servers) 148 await waitJobs(servers)
149 }) 149 })
150 150
@@ -157,7 +157,7 @@ describe('Test blocklist', function () {
157 157
158 await checkNotifications(servers[0], userToken2, notifs) 158 await checkNotifications(servers[0], userToken2, notifs)
159 159
160 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, server: servers[1].host }) 160 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
161 }) 161 })
162 }) 162 })
163 163
@@ -184,7 +184,7 @@ describe('Test blocklist', function () {
184 it('Should block an account', async function () { 184 it('Should block an account', async function () {
185 this.timeout(10000) 185 this.timeout(10000)
186 186
187 await servers[0].blocklistCommand.addToServerBlocklist({ account: 'user3@' + servers[1].host }) 187 await servers[0].blocklist.addToServerBlocklist({ account: 'user3@' + servers[1].host })
188 await waitJobs(servers) 188 await waitJobs(servers)
189 }) 189 })
190 190
@@ -192,7 +192,7 @@ describe('Test blocklist', function () {
192 await checkNotifications(servers[0], userToken1, []) 192 await checkNotifications(servers[0], userToken1, [])
193 await checkNotifications(servers[0], userToken2, []) 193 await checkNotifications(servers[0], userToken2, [])
194 194
195 await servers[0].blocklistCommand.removeFromServerBlocklist({ account: 'user3@' + servers[1].host }) 195 await servers[0].blocklist.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
196 }) 196 })
197 }) 197 })
198 198
@@ -219,7 +219,7 @@ describe('Test blocklist', function () {
219 it('Should block an account', async function () { 219 it('Should block an account', async function () {
220 this.timeout(10000) 220 this.timeout(10000)
221 221
222 await servers[0].blocklistCommand.addToServerBlocklist({ server: servers[1].host }) 222 await servers[0].blocklist.addToServerBlocklist({ server: servers[1].host })
223 await waitJobs(servers) 223 await waitJobs(servers)
224 }) 224 })
225 225
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts
index 3c3b2d6fd..9a4a3b3b9 100644
--- a/server/tests/api/moderation/blocklist.ts
+++ b/server/tests/api/moderation/blocklist.ts
@@ -18,24 +18,24 @@ const expect = chai.expect
18 18
19async function checkAllVideos (server: ServerInfo, token: string) { 19async function checkAllVideos (server: ServerInfo, token: string) {
20 { 20 {
21 const { data } = await server.videosCommand.listWithToken({ token }) 21 const { data } = await server.videos.listWithToken({ token })
22 expect(data).to.have.lengthOf(5) 22 expect(data).to.have.lengthOf(5)
23 } 23 }
24 24
25 { 25 {
26 const { data } = await server.videosCommand.list() 26 const { data } = await server.videos.list()
27 expect(data).to.have.lengthOf(5) 27 expect(data).to.have.lengthOf(5)
28 } 28 }
29} 29}
30 30
31async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) { 31async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) {
32 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token }) 32 const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
33 33
34 const threads = data.filter(t => t.isDeleted === false) 34 const threads = data.filter(t => t.isDeleted === false)
35 expect(threads).to.have.lengthOf(2) 35 expect(threads).to.have.lengthOf(2)
36 36
37 for (const thread of threads) { 37 for (const thread of threads) {
38 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId: thread.id, token }) 38 const tree = await server.comments.getThread({ videoId: videoUUID, threadId: thread.id, token })
39 expect(tree.children).to.have.lengthOf(1) 39 expect(tree.children).to.have.lengthOf(1)
40 } 40 }
41} 41}
@@ -45,13 +45,13 @@ async function checkCommentNotification (
45 comment: { server: ServerInfo, token: string, videoUUID: string, text: string }, 45 comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
46 check: 'presence' | 'absence' 46 check: 'presence' | 'absence'
47) { 47) {
48 const command = comment.server.commentsCommand 48 const command = comment.server.comments
49 49
50 const { threadId, createdAt } = await command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text }) 50 const { threadId, createdAt } = await command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text })
51 51
52 await waitJobs([ mainServer, comment.server ]) 52 await waitJobs([ mainServer, comment.server ])
53 53
54 const { data } = await mainServer.notificationsCommand.list({ start: 0, count: 30 }) 54 const { data } = await mainServer.notifications.list({ start: 0, count: 30 })
55 const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt) 55 const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
56 56
57 if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1) 57 if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
@@ -80,44 +80,44 @@ describe('Test blocklist', function () {
80 servers = await flushAndRunMultipleServers(3) 80 servers = await flushAndRunMultipleServers(3)
81 await setAccessTokensToServers(servers) 81 await setAccessTokensToServers(servers)
82 82
83 command = servers[0].blocklistCommand 83 command = servers[0].blocklist
84 commentsCommand = servers.map(s => s.commentsCommand) 84 commentsCommand = servers.map(s => s.comments)
85 85
86 { 86 {
87 const user = { username: 'user1', password: 'password' } 87 const user = { username: 'user1', password: 'password' }
88 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 88 await servers[0].users.create({ username: user.username, password: user.password })
89 89
90 userToken1 = await servers[0].loginCommand.getAccessToken(user) 90 userToken1 = await servers[0].login.getAccessToken(user)
91 await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } }) 91 await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
92 } 92 }
93 93
94 { 94 {
95 const user = { username: 'moderator', password: 'password' } 95 const user = { username: 'moderator', password: 'password' }
96 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 96 await servers[0].users.create({ username: user.username, password: user.password })
97 97
98 userModeratorToken = await servers[0].loginCommand.getAccessToken(user) 98 userModeratorToken = await servers[0].login.getAccessToken(user)
99 } 99 }
100 100
101 { 101 {
102 const user = { username: 'user2', password: 'password' } 102 const user = { username: 'user2', password: 'password' }
103 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 103 await servers[1].users.create({ username: user.username, password: user.password })
104 104
105 userToken2 = await servers[1].loginCommand.getAccessToken(user) 105 userToken2 = await servers[1].login.getAccessToken(user)
106 await servers[1].videosCommand.upload({ token: userToken2, attributes: { name: 'video user 2' } }) 106 await servers[1].videos.upload({ token: userToken2, attributes: { name: 'video user 2' } })
107 } 107 }
108 108
109 { 109 {
110 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } }) 110 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
111 videoUUID1 = uuid 111 videoUUID1 = uuid
112 } 112 }
113 113
114 { 114 {
115 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } }) 115 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
116 videoUUID2 = uuid 116 videoUUID2 = uuid
117 } 117 }
118 118
119 { 119 {
120 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } }) 120 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
121 videoUUID3 = uuid 121 videoUUID3 = uuid
122 } 122 }
123 123
@@ -159,7 +159,7 @@ describe('Test blocklist', function () {
159 }) 159 })
160 160
161 it('Should hide its videos', async function () { 161 it('Should hide its videos', async function () {
162 const { data } = await servers[0].videosCommand.listWithToken() 162 const { data } = await servers[0].videos.listWithToken()
163 163
164 expect(data).to.have.lengthOf(4) 164 expect(data).to.have.lengthOf(4)
165 165
@@ -172,7 +172,7 @@ describe('Test blocklist', function () {
172 }) 172 })
173 173
174 it('Should hide its videos', async function () { 174 it('Should hide its videos', async function () {
175 const { data } = await servers[0].videosCommand.listWithToken() 175 const { data } = await servers[0].videos.listWithToken()
176 176
177 expect(data).to.have.lengthOf(3) 177 expect(data).to.have.lengthOf(3)
178 178
@@ -289,12 +289,12 @@ describe('Test blocklist', function () {
289 289
290 // Server 1 and 3 should only have uploader comments 290 // Server 1 and 3 should only have uploader comments
291 for (const server of [ servers[0], servers[2] ]) { 291 for (const server of [ servers[0], servers[2] ]) {
292 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' }) 292 const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
293 293
294 expect(data).to.have.lengthOf(1) 294 expect(data).to.have.lengthOf(1)
295 expect(data[0].text).to.equal('uploader') 295 expect(data[0].text).to.equal('uploader')
296 296
297 const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id }) 297 const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
298 298
299 if (server.serverNumber === 1) expect(tree.children).to.have.lengthOf(0) 299 if (server.serverNumber === 1) expect(tree.children).to.have.lengthOf(0)
300 else expect(tree.children).to.have.lengthOf(1) 300 else expect(tree.children).to.have.lengthOf(1)
@@ -306,7 +306,7 @@ describe('Test blocklist', function () {
306 }) 306 })
307 307
308 it('Should display its videos', async function () { 308 it('Should display its videos', async function () {
309 const { data } = await servers[0].videosCommand.listWithToken() 309 const { data } = await servers[0].videos.listWithToken()
310 expect(data).to.have.lengthOf(4) 310 expect(data).to.have.lengthOf(4)
311 311
312 const v = data.find(v => v.name === 'video user 2') 312 const v = data.find(v => v.name === 'video user 2')
@@ -315,7 +315,7 @@ describe('Test blocklist', function () {
315 315
316 it('Should display its comments on my video', async function () { 316 it('Should display its comments on my video', async function () {
317 for (const server of servers) { 317 for (const server of servers) {
318 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' }) 318 const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
319 319
320 // Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment 320 // Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment
321 if (server.serverNumber === 3) { 321 if (server.serverNumber === 3) {
@@ -327,7 +327,7 @@ describe('Test blocklist', function () {
327 expect(data[0].text).to.equal('uploader') 327 expect(data[0].text).to.equal('uploader')
328 expect(data[1].text).to.equal('comment user 2') 328 expect(data[1].text).to.equal('comment user 2')
329 329
330 const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id }) 330 const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
331 expect(tree.children).to.have.lengthOf(1) 331 expect(tree.children).to.have.lengthOf(1)
332 expect(tree.children[0].comment.text).to.equal('reply by user 2') 332 expect(tree.children[0].comment.text).to.equal('reply by user 2')
333 expect(tree.children[0].children).to.have.lengthOf(1) 333 expect(tree.children[0].children).to.have.lengthOf(1)
@@ -378,7 +378,7 @@ describe('Test blocklist', function () {
378 }) 378 })
379 379
380 it('Should hide its videos', async function () { 380 it('Should hide its videos', async function () {
381 const { data } = await servers[0].videosCommand.listWithToken() 381 const { data } = await servers[0].videos.listWithToken()
382 382
383 expect(data).to.have.lengthOf(3) 383 expect(data).to.have.lengthOf(3)
384 384
@@ -488,7 +488,7 @@ describe('Test blocklist', function () {
488 488
489 it('Should hide its videos', async function () { 489 it('Should hide its videos', async function () {
490 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 490 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
491 const { data } = await servers[0].videosCommand.listWithToken({ token }) 491 const { data } = await servers[0].videos.listWithToken({ token })
492 492
493 expect(data).to.have.lengthOf(4) 493 expect(data).to.have.lengthOf(4)
494 494
@@ -503,7 +503,7 @@ describe('Test blocklist', function () {
503 503
504 it('Should hide its videos', async function () { 504 it('Should hide its videos', async function () {
505 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 505 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
506 const { data } = await servers[0].videosCommand.listWithToken({ token }) 506 const { data } = await servers[0].videos.listWithToken({ token })
507 507
508 expect(data).to.have.lengthOf(3) 508 expect(data).to.have.lengthOf(3)
509 509
@@ -581,7 +581,7 @@ describe('Test blocklist', function () {
581 581
582 it('Should display its videos', async function () { 582 it('Should display its videos', async function () {
583 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 583 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
584 const { data } = await servers[0].videosCommand.listWithToken({ token }) 584 const { data } = await servers[0].videos.listWithToken({ token })
585 expect(data).to.have.lengthOf(4) 585 expect(data).to.have.lengthOf(4)
586 586
587 const v = data.find(v => v.name === 'video user 2') 587 const v = data.find(v => v.name === 'video user 2')
@@ -639,8 +639,8 @@ describe('Test blocklist', function () {
639 it('Should hide its videos', async function () { 639 it('Should hide its videos', async function () {
640 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 640 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
641 const requests = [ 641 const requests = [
642 servers[0].videosCommand.list(), 642 servers[0].videos.list(),
643 servers[0].videosCommand.listWithToken({ token }) 643 servers[0].videos.listWithToken({ token })
644 ] 644 ]
645 645
646 for (const req of requests) { 646 for (const req of requests) {
@@ -688,13 +688,13 @@ describe('Test blocklist', function () {
688 688
689 { 689 {
690 const now = new Date() 690 const now = new Date()
691 await servers[1].followsCommand.unfollow({ target: servers[0] }) 691 await servers[1].follows.unfollow({ target: servers[0] })
692 await waitJobs(servers) 692 await waitJobs(servers)
693 await servers[1].followsCommand.follow({ targets: [ servers[0].host ] }) 693 await servers[1].follows.follow({ targets: [ servers[0].host ] })
694 694
695 await waitJobs(servers) 695 await waitJobs(servers)
696 696
697 const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 }) 697 const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
698 const commentNotifications = data.filter(n => { 698 const commentNotifications = data.filter(n => {
699 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString() 699 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
700 }) 700 })
@@ -749,13 +749,13 @@ describe('Test blocklist', function () {
749 749
750 { 750 {
751 const now = new Date() 751 const now = new Date()
752 await servers[1].followsCommand.unfollow({ target: servers[0] }) 752 await servers[1].follows.unfollow({ target: servers[0] })
753 await waitJobs(servers) 753 await waitJobs(servers)
754 await servers[1].followsCommand.follow({ targets: [ servers[0].host ] }) 754 await servers[1].follows.follow({ targets: [ servers[0].host ] })
755 755
756 await waitJobs(servers) 756 await waitJobs(servers)
757 757
758 const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 }) 758 const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
759 const commentNotifications = data.filter(n => { 759 const commentNotifications = data.filter(n => {
760 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString() 760 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
761 }) 761 })
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts
index 2f2e678e7..d23d23bcb 100644
--- a/server/tests/api/moderation/video-blacklist.ts
+++ b/server/tests/api/moderation/video-blacklist.ts
@@ -25,10 +25,10 @@ describe('Test video blacklist', function () {
25 let command: BlacklistCommand 25 let command: BlacklistCommand
26 26
27 async function blacklistVideosOnServer (server: ServerInfo) { 27 async function blacklistVideosOnServer (server: ServerInfo) {
28 const { data } = await server.videosCommand.list() 28 const { data } = await server.videos.list()
29 29
30 for (const video of data) { 30 for (const video of data) {
31 await server.blacklistCommand.add({ videoId: video.id, reason: 'super reason' }) 31 await server.blacklist.add({ videoId: video.id, reason: 'super reason' })
32 } 32 }
33 } 33 }
34 34
@@ -45,13 +45,13 @@ describe('Test video blacklist', function () {
45 await doubleFollow(servers[0], servers[1]) 45 await doubleFollow(servers[0], servers[1])
46 46
47 // Upload 2 videos on server 2 47 // Upload 2 videos on server 2
48 await servers[1].videosCommand.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } }) 48 await servers[1].videos.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } })
49 await servers[1].videosCommand.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } }) 49 await servers[1].videos.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } })
50 50
51 // Wait videos propagation, server 2 has transcoding enabled 51 // Wait videos propagation, server 2 has transcoding enabled
52 await waitJobs(servers) 52 await waitJobs(servers)
53 53
54 command = servers[0].blacklistCommand 54 command = servers[0].blacklist
55 55
56 // Blacklist the two videos on server 1 56 // Blacklist the two videos on server 1
57 await blacklistVideosOnServer(servers[0]) 57 await blacklistVideosOnServer(servers[0])
@@ -61,7 +61,7 @@ describe('Test video blacklist', function () {
61 61
62 it('Should not have the video blacklisted in videos list/search on server 1', async function () { 62 it('Should not have the video blacklisted in videos list/search on server 1', async function () {
63 { 63 {
64 const { total, data } = await servers[0].videosCommand.list() 64 const { total, data } = await servers[0].videos.list()
65 65
66 expect(total).to.equal(0) 66 expect(total).to.equal(0)
67 expect(data).to.be.an('array') 67 expect(data).to.be.an('array')
@@ -69,7 +69,7 @@ describe('Test video blacklist', function () {
69 } 69 }
70 70
71 { 71 {
72 const body = await servers[0].searchCommand.searchVideos({ search: 'video' }) 72 const body = await servers[0].search.searchVideos({ search: 'video' })
73 73
74 expect(body.total).to.equal(0) 74 expect(body.total).to.equal(0)
75 expect(body.data).to.be.an('array') 75 expect(body.data).to.be.an('array')
@@ -79,7 +79,7 @@ describe('Test video blacklist', function () {
79 79
80 it('Should have the blacklisted video in videos list/search on server 2', async function () { 80 it('Should have the blacklisted video in videos list/search on server 2', async function () {
81 { 81 {
82 const { total, data } = await servers[1].videosCommand.list() 82 const { total, data } = await servers[1].videos.list()
83 83
84 expect(total).to.equal(2) 84 expect(total).to.equal(2)
85 expect(data).to.be.an('array') 85 expect(data).to.be.an('array')
@@ -87,7 +87,7 @@ describe('Test video blacklist', function () {
87 } 87 }
88 88
89 { 89 {
90 const body = await servers[1].searchCommand.searchVideos({ search: 'video' }) 90 const body = await servers[1].search.searchVideos({ search: 'video' })
91 91
92 expect(body.total).to.equal(2) 92 expect(body.total).to.equal(2)
93 expect(body.data).to.be.an('array') 93 expect(body.data).to.be.an('array')
@@ -181,7 +181,7 @@ describe('Test video blacklist', function () {
181 it('Should display blacklisted videos', async function () { 181 it('Should display blacklisted videos', async function () {
182 await blacklistVideosOnServer(servers[1]) 182 await blacklistVideosOnServer(servers[1])
183 183
184 const { total, data } = await servers[1].videosCommand.listMyVideos() 184 const { total, data } = await servers[1].videos.listMyVideos()
185 185
186 expect(total).to.equal(2) 186 expect(total).to.equal(2)
187 expect(data).to.have.lengthOf(2) 187 expect(data).to.have.lengthOf(2)
@@ -198,7 +198,7 @@ describe('Test video blacklist', function () {
198 let blacklist = [] 198 let blacklist = []
199 199
200 it('Should not have any video in videos list on server 1', async function () { 200 it('Should not have any video in videos list on server 1', async function () {
201 const { total, data } = await servers[0].videosCommand.list() 201 const { total, data } = await servers[0].videos.list()
202 expect(total).to.equal(0) 202 expect(total).to.equal(0)
203 expect(data).to.be.an('array') 203 expect(data).to.be.an('array')
204 expect(data.length).to.equal(0) 204 expect(data.length).to.equal(0)
@@ -215,7 +215,7 @@ describe('Test video blacklist', function () {
215 }) 215 })
216 216
217 it('Should have the ex-blacklisted video in videos list on server 1', async function () { 217 it('Should have the ex-blacklisted video in videos list on server 1', async function () {
218 const { total, data } = await servers[0].videosCommand.list() 218 const { total, data } = await servers[0].videos.list()
219 expect(total).to.equal(1) 219 expect(total).to.equal(1)
220 220
221 expect(data).to.be.an('array') 221 expect(data).to.be.an('array')
@@ -244,11 +244,11 @@ describe('Test video blacklist', function () {
244 this.timeout(10000) 244 this.timeout(10000)
245 245
246 { 246 {
247 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 3' } }) 247 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 3' } })
248 video3UUID = uuid 248 video3UUID = uuid
249 } 249 }
250 { 250 {
251 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 4' } }) 251 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 4' } })
252 video4UUID = uuid 252 video4UUID = uuid
253 } 253 }
254 254
@@ -263,12 +263,12 @@ describe('Test video blacklist', function () {
263 await waitJobs(servers) 263 await waitJobs(servers)
264 264
265 { 265 {
266 const { data } = await servers[0].videosCommand.list() 266 const { data } = await servers[0].videos.list()
267 expect(data.find(v => v.uuid === video3UUID)).to.be.undefined 267 expect(data.find(v => v.uuid === video3UUID)).to.be.undefined
268 } 268 }
269 269
270 { 270 {
271 const { data } = await servers[1].videosCommand.list() 271 const { data } = await servers[1].videos.list()
272 expect(data.find(v => v.uuid === video3UUID)).to.not.be.undefined 272 expect(data.find(v => v.uuid === video3UUID)).to.not.be.undefined
273 } 273 }
274 }) 274 })
@@ -281,7 +281,7 @@ describe('Test video blacklist', function () {
281 await waitJobs(servers) 281 await waitJobs(servers)
282 282
283 for (const server of servers) { 283 for (const server of servers) {
284 const { data } = await server.videosCommand.list() 284 const { data } = await server.videos.list()
285 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined 285 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
286 } 286 }
287 }) 287 })
@@ -289,12 +289,12 @@ describe('Test video blacklist', function () {
289 it('Should have the video unfederated even after an Update AP message', async function () { 289 it('Should have the video unfederated even after an Update AP message', async function () {
290 this.timeout(10000) 290 this.timeout(10000)
291 291
292 await servers[0].videosCommand.update({ id: video4UUID, attributes: { description: 'super description' } }) 292 await servers[0].videos.update({ id: video4UUID, attributes: { description: 'super description' } })
293 293
294 await waitJobs(servers) 294 await waitJobs(servers)
295 295
296 for (const server of servers) { 296 for (const server of servers) {
297 const { data } = await server.videosCommand.list() 297 const { data } = await server.videos.list()
298 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined 298 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
299 } 299 }
300 }) 300 })
@@ -318,7 +318,7 @@ describe('Test video blacklist', function () {
318 await waitJobs(servers) 318 await waitJobs(servers)
319 319
320 for (const server of servers) { 320 for (const server of servers) {
321 const { data } = await server.videosCommand.list() 321 const { data } = await server.videos.list()
322 expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined 322 expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined
323 } 323 }
324 }) 324 })
@@ -348,36 +348,36 @@ describe('Test video blacklist', function () {
348 348
349 { 349 {
350 const user = { username: 'user_without_flag', password: 'password' } 350 const user = { username: 'user_without_flag', password: 'password' }
351 await servers[0].usersCommand.create({ 351 await servers[0].users.create({
352 username: user.username, 352 username: user.username,
353 adminFlags: UserAdminFlag.NONE, 353 adminFlags: UserAdminFlag.NONE,
354 password: user.password, 354 password: user.password,
355 role: UserRole.USER 355 role: UserRole.USER
356 }) 356 })
357 357
358 userWithoutFlag = await servers[0].loginCommand.getAccessToken(user) 358 userWithoutFlag = await servers[0].login.getAccessToken(user)
359 359
360 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: userWithoutFlag }) 360 const { videoChannels } = await servers[0].users.getMyInfo({ token: userWithoutFlag })
361 channelOfUserWithoutFlag = videoChannels[0].id 361 channelOfUserWithoutFlag = videoChannels[0].id
362 } 362 }
363 363
364 { 364 {
365 const user = { username: 'user_with_flag', password: 'password' } 365 const user = { username: 'user_with_flag', password: 'password' }
366 await servers[0].usersCommand.create({ 366 await servers[0].users.create({
367 username: user.username, 367 username: user.username,
368 adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST, 368 adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST,
369 password: user.password, 369 password: user.password,
370 role: UserRole.USER 370 role: UserRole.USER
371 }) 371 })
372 372
373 userWithFlag = await servers[0].loginCommand.getAccessToken(user) 373 userWithFlag = await servers[0].login.getAccessToken(user)
374 } 374 }
375 375
376 await waitJobs(servers) 376 await waitJobs(servers)
377 }) 377 })
378 378
379 it('Should auto blacklist a video on upload', async function () { 379 it('Should auto blacklist a video on upload', async function () {
380 await servers[0].videosCommand.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } }) 380 await servers[0].videos.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } })
381 381
382 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 382 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
383 expect(body.total).to.equal(1) 383 expect(body.total).to.equal(1)
@@ -392,7 +392,7 @@ describe('Test video blacklist', function () {
392 name: 'URL import', 392 name: 'URL import',
393 channelId: channelOfUserWithoutFlag 393 channelId: channelOfUserWithoutFlag
394 } 394 }
395 await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes }) 395 await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
396 396
397 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 397 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
398 expect(body.total).to.equal(2) 398 expect(body.total).to.equal(2)
@@ -405,7 +405,7 @@ describe('Test video blacklist', function () {
405 name: 'Torrent import', 405 name: 'Torrent import',
406 channelId: channelOfUserWithoutFlag 406 channelId: channelOfUserWithoutFlag
407 } 407 }
408 await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes }) 408 await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
409 409
410 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 410 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
411 expect(body.total).to.equal(3) 411 expect(body.total).to.equal(3)
@@ -413,7 +413,7 @@ describe('Test video blacklist', function () {
413 }) 413 })
414 414
415 it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () { 415 it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () {
416 await servers[0].videosCommand.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } }) 416 await servers[0].videos.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } })
417 417
418 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 418 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
419 expect(body.total).to.equal(3) 419 expect(body.total).to.equal(3)