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