aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications/moderation-notifications.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/notifications/moderation-notifications.ts')
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts92
1 files changed, 48 insertions, 44 deletions
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 6f74709b3..eb3c29fe7 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -67,7 +67,7 @@ describe('Test moderation notifications', function () {
67 await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }) 67 await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' })
68 68
69 await waitJobs(servers) 69 await waitJobs(servers)
70 await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') 70 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
71 }) 71 })
72 72
73 it('Should send a notification to moderators on remote video abuse', async function () { 73 it('Should send a notification to moderators on remote video abuse', async function () {
@@ -82,7 +82,7 @@ describe('Test moderation notifications', function () {
82 await servers[1].abuses.report({ videoId, reason: 'super reason' }) 82 await servers[1].abuses.report({ videoId, reason: 'super reason' })
83 83
84 await waitJobs(servers) 84 await waitJobs(servers)
85 await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') 85 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
86 }) 86 })
87 87
88 it('Should send a notification to moderators on local comment abuse', async function () { 88 it('Should send a notification to moderators on local comment abuse', async function () {
@@ -101,7 +101,7 @@ describe('Test moderation notifications', function () {
101 await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' }) 101 await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' })
102 102
103 await waitJobs(servers) 103 await waitJobs(servers)
104 await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') 104 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
105 }) 105 })
106 106
107 it('Should send a notification to moderators on remote comment abuse', async function () { 107 it('Should send a notification to moderators on remote comment abuse', async function () {
@@ -123,7 +123,7 @@ describe('Test moderation notifications', function () {
123 await servers[1].abuses.report({ commentId, reason: 'super reason' }) 123 await servers[1].abuses.report({ commentId, reason: 'super reason' })
124 124
125 await waitJobs(servers) 125 await waitJobs(servers)
126 await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') 126 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
127 }) 127 })
128 128
129 it('Should send a notification to moderators on local account abuse', async function () { 129 it('Should send a notification to moderators on local account abuse', async function () {
@@ -136,7 +136,7 @@ describe('Test moderation notifications', function () {
136 await servers[0].abuses.report({ accountId, reason: 'super reason' }) 136 await servers[0].abuses.report({ accountId, reason: 'super reason' })
137 137
138 await waitJobs(servers) 138 await waitJobs(servers)
139 await checkNewAccountAbuseForModerators(baseParams, username, 'presence') 139 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' })
140 }) 140 })
141 141
142 it('Should send a notification to moderators on remote account abuse', async function () { 142 it('Should send a notification to moderators on remote account abuse', async function () {
@@ -152,7 +152,7 @@ describe('Test moderation notifications', function () {
152 await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' }) 152 await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' })
153 153
154 await waitJobs(servers) 154 await waitJobs(servers)
155 await checkNewAccountAbuseForModerators(baseParams, username, 'presence') 155 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' })
156 }) 156 })
157 }) 157 })
158 158
@@ -181,7 +181,7 @@ describe('Test moderation notifications', function () {
181 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } }) 181 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
182 await waitJobs(servers) 182 await waitJobs(servers)
183 183
184 await checkAbuseStateChange(baseParams, abuseId, AbuseState.ACCEPTED, 'presence') 184 await checkAbuseStateChange({ ...baseParams, abuseId, state: AbuseState.ACCEPTED, checkType: 'presence' })
185 }) 185 })
186 186
187 it('Should send a notification to reporter if the abuse has been rejected', async function () { 187 it('Should send a notification to reporter if the abuse has been rejected', async function () {
@@ -190,7 +190,7 @@ describe('Test moderation notifications', function () {
190 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } }) 190 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } })
191 await waitJobs(servers) 191 await waitJobs(servers)
192 192
193 await checkAbuseStateChange(baseParams, abuseId, AbuseState.REJECTED, 'presence') 193 await checkAbuseStateChange({ ...baseParams, abuseId, state: AbuseState.REJECTED, checkType: 'presence' })
194 }) 194 })
195 }) 195 })
196 196
@@ -236,7 +236,7 @@ describe('Test moderation notifications', function () {
236 await servers[0].abuses.addMessage({ abuseId, message }) 236 await servers[0].abuses.addMessage({ abuseId, message })
237 await waitJobs(servers) 237 await waitJobs(servers)
238 238
239 await checkNewAbuseMessage(baseParamsUser, abuseId, message, 'user_1@example.com', 'presence') 239 await checkNewAbuseMessage({ ...baseParamsUser, abuseId, message, toEmail: 'user_1@example.com', checkType: 'presence' })
240 }) 240 })
241 241
242 it('Should not send a notification to the admin if sent by the admin', async function () { 242 it('Should not send a notification to the admin if sent by the admin', async function () {
@@ -246,7 +246,8 @@ describe('Test moderation notifications', function () {
246 await servers[0].abuses.addMessage({ abuseId, message }) 246 await servers[0].abuses.addMessage({ abuseId, message })
247 await waitJobs(servers) 247 await waitJobs(servers)
248 248
249 await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence') 249 const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'
250 await checkNewAbuseMessage({ ...baseParamsAdmin, abuseId, message, toEmail, checkType: 'absence' })
250 }) 251 })
251 252
252 it('Should send a notification to moderators', async function () { 253 it('Should send a notification to moderators', async function () {
@@ -256,7 +257,8 @@ describe('Test moderation notifications', function () {
256 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 257 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
257 await waitJobs(servers) 258 await waitJobs(servers)
258 259
259 await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence') 260 const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'
261 await checkNewAbuseMessage({ ...baseParamsAdmin, abuseId: abuseId2, message, toEmail, checkType: 'presence' })
260 }) 262 })
261 263
262 it('Should not send a notification to reporter if sent by the reporter', async function () { 264 it('Should not send a notification to reporter if sent by the reporter', async function () {
@@ -266,7 +268,8 @@ describe('Test moderation notifications', function () {
266 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 268 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
267 await waitJobs(servers) 269 await waitJobs(servers)
268 270
269 await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence') 271 const toEmail = 'user_1@example.com'
272 await checkNewAbuseMessage({ ...baseParamsUser, abuseId: abuseId2, message, toEmail, checkType: 'absence' })
270 }) 273 })
271 }) 274 })
272 275
@@ -286,19 +289,19 @@ describe('Test moderation notifications', function () {
286 this.timeout(10000) 289 this.timeout(10000)
287 290
288 const name = 'video for abuse ' + buildUUID() 291 const name = 'video for abuse ' + buildUUID()
289 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 292 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
290 293
291 await servers[0].blacklist.add({ videoId: uuid }) 294 await servers[0].blacklist.add({ videoId: uuid })
292 295
293 await waitJobs(servers) 296 await waitJobs(servers)
294 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist') 297 await checkNewBlacklistOnMyVideo({ ...baseParams, shortUUID, videoName: name, blacklistType: 'blacklist' })
295 }) 298 })
296 299
297 it('Should send a notification to video owner on unblacklist', async function () { 300 it('Should send a notification to video owner on unblacklist', async function () {
298 this.timeout(10000) 301 this.timeout(10000)
299 302
300 const name = 'video for abuse ' + buildUUID() 303 const name = 'video for abuse ' + buildUUID()
301 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 304 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
302 305
303 await servers[0].blacklist.add({ videoId: uuid }) 306 await servers[0].blacklist.add({ videoId: uuid })
304 307
@@ -307,7 +310,7 @@ describe('Test moderation notifications', function () {
307 await waitJobs(servers) 310 await waitJobs(servers)
308 311
309 await wait(500) 312 await wait(500)
310 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'unblacklist') 313 await checkNewBlacklistOnMyVideo({ ...baseParams, shortUUID, videoName: name, blacklistType: 'unblacklist' })
311 }) 314 })
312 }) 315 })
313 316
@@ -330,10 +333,10 @@ describe('Test moderation notifications', function () {
330 333
331 await waitJobs(servers) 334 await waitJobs(servers)
332 335
333 await checkUserRegistered(baseParams, 'user_45', 'presence') 336 await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' })
334 337
335 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 338 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
336 await checkUserRegistered({ ...baseParams, ...userOverride }, 'user_45', 'absence') 339 await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' })
337 }) 340 })
338 }) 341 })
339 342
@@ -372,10 +375,10 @@ describe('Test moderation notifications', function () {
372 375
373 await waitJobs(servers) 376 await waitJobs(servers)
374 377
375 await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence') 378 await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' })
376 379
377 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 380 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
378 await checkNewInstanceFollower({ ...baseParams, ...userOverride }, 'localhost:' + servers[2].port, 'absence') 381 await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' })
379 }) 382 })
380 383
381 it('Should send a notification on auto follow back', async function () { 384 it('Should send a notification on auto follow back', async function () {
@@ -399,10 +402,10 @@ describe('Test moderation notifications', function () {
399 402
400 const followerHost = servers[0].host 403 const followerHost = servers[0].host
401 const followingHost = servers[2].host 404 const followingHost = servers[2].host
402 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') 405 await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' })
403 406
404 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 407 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
405 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence') 408 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' })
406 409
407 config.followings.instance.autoFollowBack.enabled = false 410 config.followings.instance.autoFollowBack.enabled = false
408 await servers[0].config.updateCustomSubConfig({ newConfig: config }) 411 await servers[0].config.updateCustomSubConfig({ newConfig: config })
@@ -421,7 +424,7 @@ describe('Test moderation notifications', function () {
421 424
422 const followerHost = servers[0].host 425 const followerHost = servers[0].host
423 const followingHost = servers[1].host 426 const followingHost = servers[1].host
424 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') 427 await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' })
425 428
426 config.followings.instance.autoFollowIndex.enabled = false 429 config.followings.instance.autoFollowIndex.enabled = false
427 await servers[0].config.updateCustomSubConfig({ newConfig: config }) 430 await servers[0].config.updateCustomSubConfig({ newConfig: config })
@@ -433,7 +436,8 @@ describe('Test moderation notifications', function () {
433 let userBaseParams: CheckerBaseParams 436 let userBaseParams: CheckerBaseParams
434 let adminBaseParamsServer1: CheckerBaseParams 437 let adminBaseParamsServer1: CheckerBaseParams
435 let adminBaseParamsServer2: CheckerBaseParams 438 let adminBaseParamsServer2: CheckerBaseParams
436 let videoUUID: string 439 let uuid: string
440 let shortUUID: string
437 let videoName: string 441 let videoName: string
438 let currentCustomConfig: CustomConfig 442 let currentCustomConfig: CustomConfig
439 443
@@ -480,36 +484,36 @@ describe('Test moderation notifications', function () {
480 484
481 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 485 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
482 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 486 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
483
484 }) 487 })
485 488
486 it('Should send notification to moderators on new video with auto-blacklist', async function () { 489 it('Should send notification to moderators on new video with auto-blacklist', async function () {
487 this.timeout(40000) 490 this.timeout(40000)
488 491
489 videoName = 'video with auto-blacklist ' + buildUUID() 492 videoName = 'video with auto-blacklist ' + buildUUID()
490 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } }) 493 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } })
491 videoUUID = uuid 494 shortUUID = video.shortUUID
495 uuid = video.uuid
492 496
493 await waitJobs(servers) 497 await waitJobs(servers)
494 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence') 498 await checkVideoAutoBlacklistForModerators({ ...adminBaseParamsServer1, shortUUID, videoName, checkType: 'presence' })
495 }) 499 })
496 500
497 it('Should not send video publish notification if auto-blacklisted', async function () { 501 it('Should not send video publish notification if auto-blacklisted', async function () {
498 await checkVideoIsPublished(userBaseParams, videoName, videoUUID, 'absence') 502 await checkVideoIsPublished({ ...userBaseParams, videoName, shortUUID, checkType: 'absence' })
499 }) 503 })
500 504
501 it('Should not send a local user subscription notification if auto-blacklisted', async function () { 505 it('Should not send a local user subscription notification if auto-blacklisted', async function () {
502 await checkNewVideoFromSubscription(adminBaseParamsServer1, videoName, videoUUID, 'absence') 506 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName, shortUUID, checkType: 'absence' })
503 }) 507 })
504 508
505 it('Should not send a remote user subscription notification if auto-blacklisted', async function () { 509 it('Should not send a remote user subscription notification if auto-blacklisted', async function () {
506 await checkNewVideoFromSubscription(adminBaseParamsServer2, videoName, videoUUID, 'absence') 510 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName, shortUUID, checkType: 'absence' })
507 }) 511 })
508 512
509 it('Should send video published and unblacklist after video unblacklisted', async function () { 513 it('Should send video published and unblacklist after video unblacklisted', async function () {
510 this.timeout(40000) 514 this.timeout(40000)
511 515
512 await servers[0].blacklist.remove({ videoId: videoUUID }) 516 await servers[0].blacklist.remove({ videoId: uuid })
513 517
514 await waitJobs(servers) 518 await waitJobs(servers)
515 519
@@ -520,11 +524,11 @@ describe('Test moderation notifications', function () {
520 }) 524 })
521 525
522 it('Should send a local user subscription notification after removed from blacklist', async function () { 526 it('Should send a local user subscription notification after removed from blacklist', async function () {
523 await checkNewVideoFromSubscription(adminBaseParamsServer1, videoName, videoUUID, 'presence') 527 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName, shortUUID, checkType: 'presence' })
524 }) 528 })
525 529
526 it('Should send a remote user subscription notification after removed from blacklist', async function () { 530 it('Should send a remote user subscription notification after removed from blacklist', async function () {
527 await checkNewVideoFromSubscription(adminBaseParamsServer2, videoName, videoUUID, 'presence') 531 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName, shortUUID, checkType: 'presence' })
528 }) 532 })
529 533
530 it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () { 534 it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
@@ -543,19 +547,19 @@ describe('Test moderation notifications', function () {
543 } 547 }
544 } 548 }
545 549
546 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes }) 550 const { shortUUID, uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
547 551
548 await servers[0].blacklist.remove({ videoId: uuid }) 552 await servers[0].blacklist.remove({ videoId: uuid })
549 553
550 await waitJobs(servers) 554 await waitJobs(servers)
551 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist') 555 await checkNewBlacklistOnMyVideo({ ...userBaseParams, shortUUID, videoName: name, blacklistType: 'unblacklist' })
552 556
553 // FIXME: Can't test absence as two notifications sent to same user and util only checks last one 557 // FIXME: Can't test absence as two notifications sent to same user and util only checks last one
554 // One notification might be better anyways 558 // One notification might be better anyways
555 // await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') 559 // await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
556 560
557 await checkNewVideoFromSubscription(adminBaseParamsServer1, name, uuid, 'absence') 561 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName: name, shortUUID, checkType: 'absence' })
558 await checkNewVideoFromSubscription(adminBaseParamsServer2, name, uuid, 'absence') 562 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName: name, shortUUID, checkType: 'absence' })
559 }) 563 })
560 564
561 it('Should not send publish/subscription notifications after scheduled update if video still auto-blacklisted', async function () { 565 it('Should not send publish/subscription notifications after scheduled update if video still auto-blacklisted', async function () {
@@ -575,12 +579,12 @@ describe('Test moderation notifications', function () {
575 } 579 }
576 } 580 }
577 581
578 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes }) 582 const { shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes })
579 583
580 await wait(6000) 584 await wait(6000)
581 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') 585 await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' })
582 await checkNewVideoFromSubscription(adminBaseParamsServer1, name, uuid, 'absence') 586 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName: name, shortUUID, checkType: 'absence' })
583 await checkNewVideoFromSubscription(adminBaseParamsServer2, name, uuid, 'absence') 587 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName: name, shortUUID, checkType: 'absence' })
584 }) 588 })
585 589
586 it('Should not send a notification to moderators on new video without auto-blacklist', async function () { 590 it('Should not send a notification to moderators on new video without auto-blacklist', async function () {
@@ -589,10 +593,10 @@ describe('Test moderation notifications', function () {
589 const name = 'video without auto-blacklist ' + buildUUID() 593 const name = 'video without auto-blacklist ' + buildUUID()
590 594
591 // admin with blacklist right will not be auto-blacklisted 595 // admin with blacklist right will not be auto-blacklisted
592 const { uuid } = await servers[0].videos.upload({ attributes: { name } }) 596 const { shortUUID } = await servers[0].videos.upload({ attributes: { name } })
593 597
594 await waitJobs(servers) 598 await waitJobs(servers)
595 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') 599 await checkVideoAutoBlacklistForModerators({ ...adminBaseParamsServer1, shortUUID, videoName: name, checkType: 'absence' })
596 }) 600 })
597 601
598 after(async () => { 602 after(async () => {