]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/notifications/moderation-notifications.ts
Add filter:api.server.stats.get.result hook
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / moderation-notifications.ts
CommitLineData
8eb07b01
C
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
d4a8e7a6 4import { buildUUID } from '@server/helpers/uuid'
8eb07b01 5import {
0c1a77e9
C
6 checkAbuseStateChange,
7 checkAutoInstanceFollowing,
8 CheckerBaseParams,
9 checkNewAbuseMessage,
10 checkNewAccountAbuseForModerators,
11 checkNewBlacklistOnMyVideo,
12 checkNewCommentAbuseForModerators,
13 checkNewInstanceFollower,
14 checkNewVideoAbuseForModerators,
15 checkNewVideoFromSubscription,
16 checkUserRegistered,
17 checkVideoAutoBlacklistForModerators,
18 checkVideoIsPublished,
8eb07b01 19 cleanupTests,
8eb07b01 20 MockInstancesIndex,
0c1a77e9 21 MockSmtpServer,
254d3579 22 PeerTubeServer,
4c7e60bc 23 prepareNotificationsTest,
0c1a77e9
C
24 wait,
25 waitJobs
26} from '@shared/extra-utils'
27import { AbuseState, CustomConfig, UserNotification, VideoPrivacy } from '@shared/models'
8eb07b01
C
28
29describe('Test moderation notifications', function () {
254d3579 30 let servers: PeerTubeServer[] = []
8eb07b01
C
31 let userAccessToken: string
32 let userNotifications: UserNotification[] = []
33 let adminNotifications: UserNotification[] = []
34 let adminNotificationsServer2: UserNotification[] = []
35 let emails: object[] = []
36
37 before(async function () {
38 this.timeout(120000)
39
40 const res = await prepareNotificationsTest(3)
41 emails = res.emails
42 userAccessToken = res.userAccessToken
43 servers = res.servers
44 userNotifications = res.userNotifications
45 adminNotifications = res.adminNotifications
46 adminNotificationsServer2 = res.adminNotificationsServer2
47 })
48
594d3e48 49 describe('Abuse for moderators notification', function () {
8eb07b01
C
50 let baseParams: CheckerBaseParams
51
52 before(() => {
53 baseParams = {
54 server: servers[0],
55 emails,
56 socketNotifications: adminNotifications,
57 token: servers[0].accessToken
58 }
59 })
60
61 it('Should send a notification to moderators on local video abuse', async function () {
20516920 62 this.timeout(20000)
8eb07b01 63
d4a8e7a6 64 const name = 'video for abuse ' + buildUUID()
89d241a7 65 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
8eb07b01 66
89d241a7 67 await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' })
8eb07b01
C
68
69 await waitJobs(servers)
29837f88 70 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
8eb07b01
C
71 })
72
73 it('Should send a notification to moderators on remote video abuse', async function () {
20516920 74 this.timeout(20000)
8eb07b01 75
d4a8e7a6 76 const name = 'video for abuse ' + buildUUID()
89d241a7 77 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
8eb07b01
C
78
79 await waitJobs(servers)
80
89d241a7
C
81 const videoId = await servers[1].videos.getId({ uuid: video.uuid })
82 await servers[1].abuses.report({ videoId, reason: 'super reason' })
8eb07b01
C
83
84 await waitJobs(servers)
29837f88 85 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
8eb07b01 86 })
310b5219
C
87
88 it('Should send a notification to moderators on local comment abuse', async function () {
20516920 89 this.timeout(20000)
310b5219 90
d4a8e7a6 91 const name = 'video for abuse ' + buildUUID()
89d241a7
C
92 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
93 const comment = await servers[0].comments.createThread({
12edc149
C
94 token: userAccessToken,
95 videoId: video.id,
96 text: 'comment abuse ' + buildUUID()
97 })
310b5219 98
15bedeeb
C
99 await waitJobs(servers)
100
89d241a7 101 await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' })
310b5219
C
102
103 await waitJobs(servers)
29837f88 104 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
310b5219
C
105 })
106
107 it('Should send a notification to moderators on remote comment abuse', async function () {
20516920 108 this.timeout(20000)
310b5219 109
d4a8e7a6 110 const name = 'video for abuse ' + buildUUID()
89d241a7 111 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
12edc149 112
89d241a7 113 await servers[0].comments.createThread({
12edc149
C
114 token: userAccessToken,
115 videoId: video.id,
116 text: 'comment abuse ' + buildUUID()
117 })
310b5219
C
118
119 await waitJobs(servers)
120
89d241a7 121 const { data } = await servers[1].comments.listThreads({ videoId: video.uuid })
12edc149 122 const commentId = data[0].id
89d241a7 123 await servers[1].abuses.report({ commentId, reason: 'super reason' })
310b5219
C
124
125 await waitJobs(servers)
29837f88 126 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
310b5219
C
127 })
128
129 it('Should send a notification to moderators on local account abuse', async function () {
20516920 130 this.timeout(20000)
310b5219
C
131
132 const username = 'user' + new Date().getTime()
89d241a7 133 const { account } = await servers[0].users.create({ username, password: 'donald' })
7926c5f9 134 const accountId = account.id
310b5219 135
89d241a7 136 await servers[0].abuses.report({ accountId, reason: 'super reason' })
310b5219
C
137
138 await waitJobs(servers)
29837f88 139 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' })
310b5219
C
140 })
141
142 it('Should send a notification to moderators on remote account abuse', async function () {
20516920 143 this.timeout(20000)
310b5219
C
144
145 const username = 'user' + new Date().getTime()
89d241a7
C
146 const tmpToken = await servers[0].users.generateUserAndToken(username)
147 await servers[0].videos.upload({ token: tmpToken, attributes: { name: 'super video' } })
310b5219
C
148
149 await waitJobs(servers)
150
89d241a7
C
151 const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host })
152 await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' })
310b5219
C
153
154 await waitJobs(servers)
29837f88 155 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' })
310b5219 156 })
8eb07b01
C
157 })
158
594d3e48
C
159 describe('Abuse state change notification', function () {
160 let baseParams: CheckerBaseParams
161 let abuseId: number
162
163 before(async function () {
164 baseParams = {
165 server: servers[0],
166 emails,
167 socketNotifications: userNotifications,
168 token: userAccessToken
169 }
170
d4a8e7a6 171 const name = 'abuse ' + buildUUID()
89d241a7 172 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
594d3e48 173
89d241a7 174 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
0c1a77e9 175 abuseId = body.abuse.id
594d3e48
C
176 })
177
178 it('Should send a notification to reporter if the abuse has been accepted', async function () {
179 this.timeout(10000)
180
89d241a7 181 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
594d3e48
C
182 await waitJobs(servers)
183
29837f88 184 await checkAbuseStateChange({ ...baseParams, abuseId, state: AbuseState.ACCEPTED, checkType: 'presence' })
594d3e48
C
185 })
186
187 it('Should send a notification to reporter if the abuse has been rejected', async function () {
188 this.timeout(10000)
189
89d241a7 190 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } })
594d3e48
C
191 await waitJobs(servers)
192
29837f88 193 await checkAbuseStateChange({ ...baseParams, abuseId, state: AbuseState.REJECTED, checkType: 'presence' })
594d3e48
C
194 })
195 })
196
197 describe('New abuse message notification', function () {
198 let baseParamsUser: CheckerBaseParams
199 let baseParamsAdmin: CheckerBaseParams
200 let abuseId: number
201 let abuseId2: number
202
203 before(async function () {
204 baseParamsUser = {
205 server: servers[0],
206 emails,
207 socketNotifications: userNotifications,
208 token: userAccessToken
209 }
210
211 baseParamsAdmin = {
212 server: servers[0],
213 emails,
214 socketNotifications: adminNotifications,
215 token: servers[0].accessToken
216 }
217
d4a8e7a6 218 const name = 'abuse ' + buildUUID()
89d241a7 219 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
594d3e48
C
220
221 {
89d241a7 222 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
0c1a77e9 223 abuseId = body.abuse.id
594d3e48
C
224 }
225
226 {
89d241a7 227 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
0c1a77e9 228 abuseId2 = body.abuse.id
594d3e48
C
229 }
230 })
231
232 it('Should send a notification to reporter on new message', async function () {
233 this.timeout(10000)
234
235 const message = 'my super message to users'
89d241a7 236 await servers[0].abuses.addMessage({ abuseId, message })
594d3e48
C
237 await waitJobs(servers)
238
29837f88 239 await checkNewAbuseMessage({ ...baseParamsUser, abuseId, message, toEmail: 'user_1@example.com', checkType: 'presence' })
594d3e48
C
240 })
241
242 it('Should not send a notification to the admin if sent by the admin', async function () {
243 this.timeout(10000)
244
245 const message = 'my super message that should not be sent to the admin'
89d241a7 246 await servers[0].abuses.addMessage({ abuseId, message })
594d3e48
C
247 await waitJobs(servers)
248
29837f88
C
249 const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'
250 await checkNewAbuseMessage({ ...baseParamsAdmin, abuseId, message, toEmail, checkType: 'absence' })
594d3e48
C
251 })
252
253 it('Should send a notification to moderators', async function () {
254 this.timeout(10000)
255
256 const message = 'my super message to moderators'
89d241a7 257 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
594d3e48
C
258 await waitJobs(servers)
259
29837f88
C
260 const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'
261 await checkNewAbuseMessage({ ...baseParamsAdmin, abuseId: abuseId2, message, toEmail, checkType: 'presence' })
594d3e48
C
262 })
263
264 it('Should not send a notification to reporter if sent by the reporter', async function () {
265 this.timeout(10000)
266
267 const message = 'my super message that should not be sent to reporter'
89d241a7 268 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
594d3e48
C
269 await waitJobs(servers)
270
29837f88
C
271 const toEmail = 'user_1@example.com'
272 await checkNewAbuseMessage({ ...baseParamsUser, abuseId: abuseId2, message, toEmail, checkType: 'absence' })
594d3e48
C
273 })
274 })
275
8eb07b01
C
276 describe('Video blacklist on my video', function () {
277 let baseParams: CheckerBaseParams
278
279 before(() => {
280 baseParams = {
281 server: servers[0],
282 emails,
283 socketNotifications: userNotifications,
284 token: userAccessToken
285 }
286 })
287
288 it('Should send a notification to video owner on blacklist', async function () {
289 this.timeout(10000)
290
d4a8e7a6 291 const name = 'video for abuse ' + buildUUID()
29837f88 292 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
8eb07b01 293
89d241a7 294 await servers[0].blacklist.add({ videoId: uuid })
8eb07b01
C
295
296 await waitJobs(servers)
29837f88 297 await checkNewBlacklistOnMyVideo({ ...baseParams, shortUUID, videoName: name, blacklistType: 'blacklist' })
8eb07b01
C
298 })
299
300 it('Should send a notification to video owner on unblacklist', async function () {
301 this.timeout(10000)
302
d4a8e7a6 303 const name = 'video for abuse ' + buildUUID()
29837f88 304 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
8eb07b01 305
89d241a7 306 await servers[0].blacklist.add({ videoId: uuid })
8eb07b01
C
307
308 await waitJobs(servers)
89d241a7 309 await servers[0].blacklist.remove({ videoId: uuid })
8eb07b01
C
310 await waitJobs(servers)
311
312 await wait(500)
29837f88 313 await checkNewBlacklistOnMyVideo({ ...baseParams, shortUUID, videoName: name, blacklistType: 'unblacklist' })
8eb07b01
C
314 })
315 })
316
317 describe('New registration', function () {
318 let baseParams: CheckerBaseParams
319
320 before(() => {
321 baseParams = {
322 server: servers[0],
323 emails,
324 socketNotifications: adminNotifications,
325 token: servers[0].accessToken
326 }
327 })
328
329 it('Should send a notification only to moderators when a user registers on the instance', async function () {
330 this.timeout(10000)
331
89d241a7 332 await servers[0].users.register({ username: 'user_45' })
8eb07b01
C
333
334 await waitJobs(servers)
335
29837f88 336 await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' })
8eb07b01
C
337
338 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
29837f88 339 await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' })
8eb07b01
C
340 })
341 })
342
343 describe('New instance follows', function () {
344 const instanceIndexServer = new MockInstancesIndex()
f6500729 345 let config: any
8eb07b01
C
346 let baseParams: CheckerBaseParams
347
348 before(async () => {
349 baseParams = {
350 server: servers[0],
351 emails,
352 socketNotifications: adminNotifications,
353 token: servers[0].accessToken
354 }
355
f6500729 356 const port = await instanceIndexServer.initialize()
8eb07b01 357 instanceIndexServer.addInstance(servers[1].host)
f6500729
C
358
359 config = {
360 followings: {
361 instance: {
362 autoFollowIndex: {
363 indexUrl: `http://localhost:${port}/api/v1/instances/hosts`,
364 enabled: true
365 }
366 }
367 }
368 }
8eb07b01
C
369 })
370
371 it('Should send a notification only to admin when there is a new instance follower', async function () {
372 this.timeout(20000)
373
4d029ef8 374 await servers[2].follows.follow({ hosts: [ servers[0].url ] })
8eb07b01
C
375
376 await waitJobs(servers)
377
29837f88 378 await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' })
8eb07b01
C
379
380 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
29837f88 381 await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' })
8eb07b01
C
382 })
383
384 it('Should send a notification on auto follow back', async function () {
385 this.timeout(40000)
386
89d241a7 387 await servers[2].follows.unfollow({ target: servers[0] })
8eb07b01
C
388 await waitJobs(servers)
389
390 const config = {
391 followings: {
392 instance: {
393 autoFollowBack: { enabled: true }
394 }
395 }
396 }
89d241a7 397 await servers[0].config.updateCustomSubConfig({ newConfig: config })
8eb07b01 398
4d029ef8 399 await servers[2].follows.follow({ hosts: [ servers[0].url ] })
8eb07b01
C
400
401 await waitJobs(servers)
402
403 const followerHost = servers[0].host
404 const followingHost = servers[2].host
29837f88 405 await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' })
8eb07b01
C
406
407 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
29837f88 408 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' })
8eb07b01
C
409
410 config.followings.instance.autoFollowBack.enabled = false
89d241a7
C
411 await servers[0].config.updateCustomSubConfig({ newConfig: config })
412 await servers[0].follows.unfollow({ target: servers[2] })
413 await servers[2].follows.unfollow({ target: servers[0] })
8eb07b01
C
414 })
415
416 it('Should send a notification on auto instances index follow', async function () {
417 this.timeout(30000)
89d241a7 418 await servers[0].follows.unfollow({ target: servers[1] })
8eb07b01 419
89d241a7 420 await servers[0].config.updateCustomSubConfig({ newConfig: config })
8eb07b01
C
421
422 await wait(5000)
423 await waitJobs(servers)
424
425 const followerHost = servers[0].host
426 const followingHost = servers[1].host
29837f88 427 await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' })
8eb07b01
C
428
429 config.followings.instance.autoFollowIndex.enabled = false
89d241a7
C
430 await servers[0].config.updateCustomSubConfig({ newConfig: config })
431 await servers[0].follows.unfollow({ target: servers[1] })
8eb07b01
C
432 })
433 })
434
435 describe('Video-related notifications when video auto-blacklist is enabled', function () {
436 let userBaseParams: CheckerBaseParams
437 let adminBaseParamsServer1: CheckerBaseParams
438 let adminBaseParamsServer2: CheckerBaseParams
29837f88
C
439 let uuid: string
440 let shortUUID: string
8eb07b01
C
441 let videoName: string
442 let currentCustomConfig: CustomConfig
443
444 before(async () => {
445
446 adminBaseParamsServer1 = {
447 server: servers[0],
448 emails,
449 socketNotifications: adminNotifications,
450 token: servers[0].accessToken
451 }
452
453 adminBaseParamsServer2 = {
454 server: servers[1],
455 emails,
456 socketNotifications: adminNotificationsServer2,
457 token: servers[1].accessToken
458 }
459
460 userBaseParams = {
461 server: servers[0],
462 emails,
463 socketNotifications: userNotifications,
464 token: userAccessToken
465 }
466
89d241a7 467 currentCustomConfig = await servers[0].config.getCustomConfig()
65e6e260 468
6c5065a0
C
469 const autoBlacklistTestsCustomConfig = {
470 ...currentCustomConfig,
471
8eb07b01
C
472 autoBlacklist: {
473 videos: {
474 ofUsers: {
475 enabled: true
476 }
477 }
478 }
6c5065a0 479 }
65e6e260 480
8eb07b01
C
481 // enable transcoding otherwise own publish notification after transcoding not expected
482 autoBlacklistTestsCustomConfig.transcoding.enabled = true
89d241a7 483 await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
8eb07b01 484
89d241a7
C
485 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
486 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
8eb07b01
C
487 })
488
489 it('Should send notification to moderators on new video with auto-blacklist', async function () {
27c3c945 490 this.timeout(120000)
8eb07b01 491
d4a8e7a6 492 videoName = 'video with auto-blacklist ' + buildUUID()
29837f88
C
493 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } })
494 shortUUID = video.shortUUID
495 uuid = video.uuid
8eb07b01
C
496
497 await waitJobs(servers)
29837f88 498 await checkVideoAutoBlacklistForModerators({ ...adminBaseParamsServer1, shortUUID, videoName, checkType: 'presence' })
8eb07b01
C
499 })
500
501 it('Should not send video publish notification if auto-blacklisted', async function () {
29837f88 502 await checkVideoIsPublished({ ...userBaseParams, videoName, shortUUID, checkType: 'absence' })
8eb07b01
C
503 })
504
505 it('Should not send a local user subscription notification if auto-blacklisted', async function () {
29837f88 506 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName, shortUUID, checkType: 'absence' })
8eb07b01
C
507 })
508
509 it('Should not send a remote user subscription notification if auto-blacklisted', async function () {
29837f88 510 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName, shortUUID, checkType: 'absence' })
8eb07b01
C
511 })
512
513 it('Should send video published and unblacklist after video unblacklisted', async function () {
34caef7f 514 this.timeout(40000)
8eb07b01 515
29837f88 516 await servers[0].blacklist.remove({ videoId: uuid })
8eb07b01
C
517
518 await waitJobs(servers)
519
520 // FIXME: Can't test as two notifications sent to same user and util only checks last one
521 // One notification might be better anyways
522 // await checkNewBlacklistOnMyVideo(userBaseParams, videoUUID, videoName, 'unblacklist')
523 // await checkVideoIsPublished(userBaseParams, videoName, videoUUID, 'presence')
524 })
525
526 it('Should send a local user subscription notification after removed from blacklist', async function () {
29837f88 527 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName, shortUUID, checkType: 'presence' })
8eb07b01
C
528 })
529
530 it('Should send a remote user subscription notification after removed from blacklist', async function () {
29837f88 531 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName, shortUUID, checkType: 'presence' })
8eb07b01
C
532 })
533
534 it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
59fd824c 535 this.timeout(40000)
8eb07b01
C
536
537 const updateAt = new Date(new Date().getTime() + 1000000)
538
d4a8e7a6 539 const name = 'video with auto-blacklist and future schedule ' + buildUUID()
8eb07b01 540
d23dd9fb 541 const attributes = {
8eb07b01
C
542 name,
543 privacy: VideoPrivacy.PRIVATE,
544 scheduleUpdate: {
545 updateAt: updateAt.toISOString(),
d23dd9fb 546 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
8eb07b01
C
547 }
548 }
549
29837f88 550 const { shortUUID, uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
8eb07b01 551
89d241a7 552 await servers[0].blacklist.remove({ videoId: uuid })
8eb07b01
C
553
554 await waitJobs(servers)
29837f88 555 await checkNewBlacklistOnMyVideo({ ...userBaseParams, shortUUID, videoName: name, blacklistType: 'unblacklist' })
8eb07b01
C
556
557 // FIXME: Can't test absence as two notifications sent to same user and util only checks last one
558 // One notification might be better anyways
559 // await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
560
29837f88
C
561 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName: name, shortUUID, checkType: 'absence' })
562 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName: name, shortUUID, checkType: 'absence' })
8eb07b01
C
563 })
564
565 it('Should not send publish/subscription notifications after scheduled update if video still auto-blacklisted', async function () {
59fd824c 566 this.timeout(40000)
8eb07b01
C
567
568 // In 2 seconds
569 const updateAt = new Date(new Date().getTime() + 2000)
570
d4a8e7a6 571 const name = 'video with schedule done and still auto-blacklisted ' + buildUUID()
8eb07b01 572
d23dd9fb 573 const attributes = {
8eb07b01
C
574 name,
575 privacy: VideoPrivacy.PRIVATE,
576 scheduleUpdate: {
577 updateAt: updateAt.toISOString(),
d23dd9fb 578 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
8eb07b01
C
579 }
580 }
581
29837f88 582 const { shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes })
8eb07b01
C
583
584 await wait(6000)
29837f88
C
585 await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' })
586 await checkNewVideoFromSubscription({ ...adminBaseParamsServer1, videoName: name, shortUUID, checkType: 'absence' })
587 await checkNewVideoFromSubscription({ ...adminBaseParamsServer2, videoName: name, shortUUID, checkType: 'absence' })
8eb07b01
C
588 })
589
590 it('Should not send a notification to moderators on new video without auto-blacklist', async function () {
26171379 591 this.timeout(60000)
8eb07b01 592
d4a8e7a6 593 const name = 'video without auto-blacklist ' + buildUUID()
8eb07b01
C
594
595 // admin with blacklist right will not be auto-blacklisted
29837f88 596 const { shortUUID } = await servers[0].videos.upload({ attributes: { name } })
8eb07b01
C
597
598 await waitJobs(servers)
29837f88 599 await checkVideoAutoBlacklistForModerators({ ...adminBaseParamsServer1, shortUUID, videoName: name, checkType: 'absence' })
8eb07b01
C
600 })
601
602 after(async () => {
89d241a7 603 await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig })
8eb07b01 604
89d241a7
C
605 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
606 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
8eb07b01
C
607 })
608 })
609
610 after(async function () {
611 MockSmtpServer.Instance.kill()
612
613 await cleanupTests(servers)
614 })
615})