aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/notifications')
-rw-r--r--server/tests/api/notifications/admin-notifications.ts10
-rw-r--r--server/tests/api/notifications/comments-notifications.ts64
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts92
-rw-r--r--server/tests/api/notifications/notifications-api.ts20
-rw-r--r--server/tests/api/notifications/user-notifications.ts94
5 files changed, 153 insertions, 127 deletions
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts
index b36ba11a9..c00d4e257 100644
--- a/server/tests/api/notifications/admin-notifications.ts
+++ b/server/tests/api/notifications/admin-notifications.ts
@@ -70,7 +70,7 @@ describe('Test admin notifications', function () {
70 joinPeerTubeServer.setLatestVersion('1.4.2') 70 joinPeerTubeServer.setLatestVersion('1.4.2')
71 71
72 await wait(3000) 72 await wait(3000)
73 await checkNewPeerTubeVersion(baseParams, '1.4.2', 'absence') 73 await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '1.4.2', checkType: 'absence' })
74 }) 74 })
75 75
76 it('Should send a notification to admins on new plugin version', async function () { 76 it('Should send a notification to admins on new plugin version', async function () {
@@ -79,7 +79,7 @@ describe('Test admin notifications', function () {
79 joinPeerTubeServer.setLatestVersion('15.4.2') 79 joinPeerTubeServer.setLatestVersion('15.4.2')
80 80
81 await wait(3000) 81 await wait(3000)
82 await checkNewPeerTubeVersion(baseParams, '15.4.2', 'presence') 82 await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '15.4.2', checkType: 'presence' })
83 }) 83 })
84 84
85 it('Should not send the same notification to admins', async function () { 85 it('Should not send the same notification to admins', async function () {
@@ -101,7 +101,7 @@ describe('Test admin notifications', function () {
101 joinPeerTubeServer.setLatestVersion('15.4.3') 101 joinPeerTubeServer.setLatestVersion('15.4.3')
102 102
103 await wait(3000) 103 await wait(3000)
104 await checkNewPeerTubeVersion(baseParams, '15.4.3', 'presence') 104 await checkNewPeerTubeVersion({ ...baseParams, latestVersion: '15.4.3', checkType: 'presence' })
105 expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) 105 expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)
106 }) 106 })
107 }) 107 })
@@ -112,7 +112,7 @@ describe('Test admin notifications', function () {
112 this.timeout(30000) 112 this.timeout(30000)
113 113
114 await wait(6000) 114 await wait(6000)
115 await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'absence') 115 await checkNewPluginVersion({ ...baseParams, pluginType: PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'absence' })
116 }) 116 })
117 117
118 it('Should send a notification to admins on new plugin version', async function () { 118 it('Should send a notification to admins on new plugin version', async function () {
@@ -122,7 +122,7 @@ describe('Test admin notifications', function () {
122 await server.sql.setPluginLatestVersion('hello-world', '0.0.1') 122 await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
123 await wait(6000) 123 await wait(6000)
124 124
125 await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence') 125 await checkNewPluginVersion({ ...baseParams, pluginType: PluginType.PLUGIN, pluginName: 'hello-world', checkType: 'presence' })
126 }) 126 })
127 127
128 it('Should not send the same notification to admins', async function () { 128 it('Should not send the same notification to admins', async function () {
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index cbb46e510..7cbb21397 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -52,25 +52,25 @@ describe('Test comments notifications', function () {
52 it('Should not send a new comment notification after a comment on another video', async function () { 52 it('Should not send a new comment notification after a comment on another video', async function () {
53 this.timeout(20000) 53 this.timeout(20000)
54 54
55 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 55 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
56 56
57 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 57 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
58 const commentId = created.id 58 const commentId = created.id
59 59
60 await waitJobs(servers) 60 await waitJobs(servers)
61 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 61 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' })
62 }) 62 })
63 63
64 it('Should not send a new comment notification if I comment my own video', async function () { 64 it('Should not send a new comment notification if I comment my own video', async function () {
65 this.timeout(20000) 65 this.timeout(20000)
66 66
67 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 67 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
68 68
69 const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' }) 69 const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' })
70 const commentId = created.id 70 const commentId = created.id
71 71
72 await waitJobs(servers) 72 await waitJobs(servers)
73 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 73 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' })
74 }) 74 })
75 75
76 it('Should not send a new comment notification if the account is muted', async function () { 76 it('Should not send a new comment notification if the account is muted', async function () {
@@ -78,13 +78,13 @@ describe('Test comments notifications', function () {
78 78
79 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }) 79 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
80 80
81 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 81 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
82 82
83 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 83 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
84 const commentId = created.id 84 const commentId = created.id
85 85
86 await waitJobs(servers) 86 await waitJobs(servers)
87 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 87 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' })
88 88
89 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }) 89 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
90 }) 90 })
@@ -92,19 +92,19 @@ describe('Test comments notifications', function () {
92 it('Should send a new comment notification after a local comment on my video', async function () { 92 it('Should send a new comment notification after a local comment on my video', async function () {
93 this.timeout(20000) 93 this.timeout(20000)
94 94
95 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 95 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
96 96
97 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 97 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
98 const commentId = created.id 98 const commentId = created.id
99 99
100 await waitJobs(servers) 100 await waitJobs(servers)
101 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') 101 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'presence' })
102 }) 102 })
103 103
104 it('Should send a new comment notification after a remote comment on my video', async function () { 104 it('Should send a new comment notification after a remote comment on my video', async function () {
105 this.timeout(20000) 105 this.timeout(20000)
106 106
107 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 107 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
108 108
109 await waitJobs(servers) 109 await waitJobs(servers)
110 110
@@ -116,26 +116,26 @@ describe('Test comments notifications', function () {
116 expect(data).to.have.lengthOf(1) 116 expect(data).to.have.lengthOf(1)
117 117
118 const commentId = data[0].id 118 const commentId = data[0].id
119 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') 119 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'presence' })
120 }) 120 })
121 121
122 it('Should send a new comment notification after a local reply on my video', async function () { 122 it('Should send a new comment notification after a local reply on my video', async function () {
123 this.timeout(20000) 123 this.timeout(20000)
124 124
125 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 125 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
126 126
127 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) 127 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
128 128
129 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) 129 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
130 130
131 await waitJobs(servers) 131 await waitJobs(servers)
132 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') 132 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId, commentId, checkType: 'presence' })
133 }) 133 })
134 134
135 it('Should send a new comment notification after a remote reply on my video', async function () { 135 it('Should send a new comment notification after a remote reply on my video', async function () {
136 this.timeout(20000) 136 this.timeout(20000)
137 137
138 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 138 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
139 await waitJobs(servers) 139 await waitJobs(servers)
140 140
141 { 141 {
@@ -155,7 +155,7 @@ describe('Test comments notifications', function () {
155 expect(tree.children).to.have.lengthOf(1) 155 expect(tree.children).to.have.lengthOf(1)
156 const commentId = tree.children[0].comment.id 156 const commentId = tree.children[0].comment.id
157 157
158 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') 158 await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId, commentId, checkType: 'presence' })
159 }) 159 })
160 160
161 it('Should convert markdown in comment to html', async function () { 161 it('Should convert markdown in comment to html', async function () {
@@ -174,6 +174,7 @@ describe('Test comments notifications', function () {
174 174
175 describe('Mention notifications', function () { 175 describe('Mention notifications', function () {
176 let baseParams: CheckerBaseParams 176 let baseParams: CheckerBaseParams
177 const byAccountDisplayName = 'super root name'
177 178
178 before(async () => { 179 before(async () => {
179 baseParams = { 180 baseParams = {
@@ -190,23 +191,23 @@ describe('Test comments notifications', function () {
190 it('Should not send a new mention comment notification if I mention the video owner', async function () { 191 it('Should not send a new mention comment notification if I mention the video owner', async function () {
191 this.timeout(10000) 192 this.timeout(10000)
192 193
193 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) 194 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
194 195
195 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) 196 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
196 197
197 await waitJobs(servers) 198 await waitJobs(servers)
198 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 199 await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })
199 }) 200 })
200 201
201 it('Should not send a new mention comment notification if I mention myself', async function () { 202 it('Should not send a new mention comment notification if I mention myself', async function () {
202 this.timeout(10000) 203 this.timeout(10000)
203 204
204 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 205 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
205 206
206 const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) 207 const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
207 208
208 await waitJobs(servers) 209 await waitJobs(servers)
209 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 210 await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })
210 }) 211 })
211 212
212 it('Should not send a new mention notification if the account is muted', async function () { 213 it('Should not send a new mention notification if the account is muted', async function () {
@@ -214,12 +215,12 @@ describe('Test comments notifications', function () {
214 215
215 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }) 216 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
216 217
217 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 218 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
218 219
219 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) 220 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
220 221
221 await waitJobs(servers) 222 await waitJobs(servers)
222 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 223 await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' })
223 224
224 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }) 225 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
225 }) 226 })
@@ -227,35 +228,37 @@ describe('Test comments notifications', function () {
227 it('Should not send a new mention notification if the remote account mention a local account', async function () { 228 it('Should not send a new mention notification if the remote account mention a local account', async function () {
228 this.timeout(20000) 229 this.timeout(20000)
229 230
230 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 231 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
231 232
232 await waitJobs(servers) 233 await waitJobs(servers)
233 const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) 234 const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
234 235
235 await waitJobs(servers) 236 await waitJobs(servers)
236 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') 237
238 const byAccountDisplayName = 'super root 2 name'
239 await checkCommentMention({ ...baseParams, shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'absence' })
237 }) 240 })
238 241
239 it('Should send a new mention notification after local comments', async function () { 242 it('Should send a new mention notification after local comments', async function () {
240 this.timeout(10000) 243 this.timeout(10000)
241 244
242 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 245 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
243 246
244 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) 247 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
245 248
246 await waitJobs(servers) 249 await waitJobs(servers)
247 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') 250 await checkCommentMention({ ...baseParams, shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'presence' })
248 251
249 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }) 252 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
250 253
251 await waitJobs(servers) 254 await waitJobs(servers)
252 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') 255 await checkCommentMention({ ...baseParams, shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })
253 }) 256 })
254 257
255 it('Should send a new mention notification after remote comments', async function () { 258 it('Should send a new mention notification after remote comments', async function () {
256 this.timeout(20000) 259 this.timeout(20000)
257 260
258 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) 261 const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
259 262
260 await waitJobs(servers) 263 await waitJobs(servers)
261 264
@@ -267,20 +270,21 @@ describe('Test comments notifications', function () {
267 const { data } = await servers[0].comments.listThreads({ videoId: uuid }) 270 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
268 expect(data).to.have.lengthOf(1) 271 expect(data).to.have.lengthOf(1)
269 272
270 const server1ThreadId = data[0].id 273 const byAccountDisplayName = 'super root 2 name'
271 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') 274 const threadId = data[0].id
275 await checkCommentMention({ ...baseParams, shortUUID, commentId: threadId, threadId, byAccountDisplayName, checkType: 'presence' })
272 276
273 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` 277 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
274 await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) 278 await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
275 279
276 await waitJobs(servers) 280 await waitJobs(servers)
277 281
278 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId: server1ThreadId }) 282 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId })
279 283
280 expect(tree.children).to.have.lengthOf(1) 284 expect(tree.children).to.have.lengthOf(1)
281 const commentId = tree.children[0].comment.id 285 const commentId = tree.children[0].comment.id
282 286
283 await checkCommentMention(baseParams, uuid, commentId, server1ThreadId, 'super root 2 name', 'presence') 287 await checkCommentMention({ ...baseParams, shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' })
284 }) 288 })
285 289
286 it('Should convert markdown in comment to html', async function () { 290 it('Should convert markdown in comment to html', async function () {
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 () => {
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index fa4b53db6..a529a9bf7 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -111,10 +111,10 @@ describe('Test notifications API', function () {
111 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) 111 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
112 } 112 }
113 113
114 const { name, uuid } = await server.videos.randomUpload() 114 const { name, shortUUID } = await server.videos.randomUpload()
115 115
116 const check = { web: true, mail: true } 116 const check = { web: true, mail: true }
117 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') 117 await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' })
118 }) 118 })
119 119
120 it('Should only have web notifications', async function () { 120 it('Should only have web notifications', async function () {
@@ -130,16 +130,16 @@ describe('Test notifications API', function () {
130 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) 130 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
131 } 131 }
132 132
133 const { name, uuid } = await server.videos.randomUpload() 133 const { name, shortUUID } = await server.videos.randomUpload()
134 134
135 { 135 {
136 const check = { mail: true, web: false } 136 const check = { mail: true, web: false }
137 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') 137 await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' })
138 } 138 }
139 139
140 { 140 {
141 const check = { mail: false, web: true } 141 const check = { mail: false, web: true }
142 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence') 142 await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'presence' })
143 } 143 }
144 }) 144 })
145 145
@@ -156,16 +156,16 @@ describe('Test notifications API', function () {
156 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) 156 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
157 } 157 }
158 158
159 const { name, uuid } = await server.videos.randomUpload() 159 const { name, shortUUID } = await server.videos.randomUpload()
160 160
161 { 161 {
162 const check = { mail: false, web: true } 162 const check = { mail: false, web: true }
163 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') 163 await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'absence' })
164 } 164 }
165 165
166 { 166 {
167 const check = { mail: true, web: false } 167 const check = { mail: true, web: false }
168 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence') 168 await checkNewVideoFromSubscription({ ...baseParams, check, videoName: name, shortUUID, checkType: 'presence' })
169 } 169 }
170 }) 170 })
171 171
@@ -187,9 +187,9 @@ describe('Test notifications API', function () {
187 ) 187 )
188 } 188 }
189 189
190 const { name, uuid } = await server.videos.randomUpload() 190 const { name, shortUUID } = await server.videos.randomUpload()
191 191
192 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 192 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
193 }) 193 })
194 }) 194 })
195 195
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index ca592d466..e53ab2aa5 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -74,8 +74,8 @@ describe('Test user notifications', function () {
74 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) 74 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
75 await waitJobs(servers) 75 await waitJobs(servers)
76 76
77 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) 77 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1)
78 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 78 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
79 }) 79 })
80 80
81 it('Should send a new video notification from a remote account', async function () { 81 it('Should send a new video notification from a remote account', async function () {
@@ -84,8 +84,8 @@ describe('Test user notifications', function () {
84 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port }) 84 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
85 await waitJobs(servers) 85 await waitJobs(servers)
86 86
87 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2) 87 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2)
88 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 88 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
89 }) 89 })
90 90
91 it('Should send a new video notification on a scheduled publication', async function () { 91 it('Should send a new video notification on a scheduled publication', async function () {
@@ -101,10 +101,10 @@ describe('Test user notifications', function () {
101 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC 101 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
102 } 102 }
103 } 103 }
104 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 104 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data)
105 105
106 await wait(6000) 106 await wait(6000)
107 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 107 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
108 }) 108 })
109 109
110 it('Should send a new video notification on a remote scheduled publication', async function () { 110 it('Should send a new video notification on a remote scheduled publication', async function () {
@@ -120,11 +120,11 @@ describe('Test user notifications', function () {
120 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC 120 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
121 } 121 }
122 } 122 }
123 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 123 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data)
124 await waitJobs(servers) 124 await waitJobs(servers)
125 125
126 await wait(6000) 126 await wait(6000)
127 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 127 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
128 }) 128 })
129 129
130 it('Should not send a notification before the video is published', async function () { 130 it('Should not send a notification before the video is published', async function () {
@@ -139,61 +139,61 @@ describe('Test user notifications', function () {
139 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC 139 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
140 } 140 }
141 } 141 }
142 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 142 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data)
143 143
144 await wait(6000) 144 await wait(6000)
145 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 145 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
146 }) 146 })
147 147
148 it('Should send a new video notification when a video becomes public', async function () { 148 it('Should send a new video notification when a video becomes public', async function () {
149 this.timeout(50000) 149 this.timeout(50000)
150 150
151 const data = { privacy: VideoPrivacy.PRIVATE } 151 const data = { privacy: VideoPrivacy.PRIVATE }
152 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 152 const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data)
153 153
154 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 154 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
155 155
156 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) 156 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
157 157
158 await waitJobs(servers) 158 await waitJobs(servers)
159 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 159 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
160 }) 160 })
161 161
162 it('Should send a new video notification when a remote video becomes public', async function () { 162 it('Should send a new video notification when a remote video becomes public', async function () {
163 this.timeout(50000) 163 this.timeout(50000)
164 164
165 const data = { privacy: VideoPrivacy.PRIVATE } 165 const data = { privacy: VideoPrivacy.PRIVATE }
166 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 166 const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data)
167 167
168 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 168 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
169 169
170 await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) 170 await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
171 171
172 await waitJobs(servers) 172 await waitJobs(servers)
173 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 173 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
174 }) 174 })
175 175
176 it('Should not send a new video notification when a video becomes unlisted', async function () { 176 it('Should not send a new video notification when a video becomes unlisted', async function () {
177 this.timeout(50000) 177 this.timeout(50000)
178 178
179 const data = { privacy: VideoPrivacy.PRIVATE } 179 const data = { privacy: VideoPrivacy.PRIVATE }
180 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 180 const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data)
181 181
182 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) 182 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
183 183
184 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 184 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
185 }) 185 })
186 186
187 it('Should not send a new video notification when a remote video becomes unlisted', async function () { 187 it('Should not send a new video notification when a remote video becomes unlisted', async function () {
188 this.timeout(50000) 188 this.timeout(50000)
189 189
190 const data = { privacy: VideoPrivacy.PRIVATE } 190 const data = { privacy: VideoPrivacy.PRIVATE }
191 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 191 const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data)
192 192
193 await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) 193 await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
194 194
195 await waitJobs(servers) 195 await waitJobs(servers)
196 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 196 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
197 }) 197 })
198 198
199 it('Should send a new video notification after a video import', async function () { 199 it('Should send a new video notification after a video import', async function () {
@@ -211,7 +211,7 @@ describe('Test user notifications', function () {
211 211
212 await waitJobs(servers) 212 await waitJobs(servers)
213 213
214 await checkNewVideoFromSubscription(baseParams, name, video.uuid, 'presence') 214 await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' })
215 }) 215 })
216 }) 216 })
217 217
@@ -230,10 +230,10 @@ describe('Test user notifications', function () {
230 it('Should not send a notification if transcoding is not enabled', async function () { 230 it('Should not send a notification if transcoding is not enabled', async function () {
231 this.timeout(50000) 231 this.timeout(50000)
232 232
233 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) 233 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1)
234 await waitJobs(servers) 234 await waitJobs(servers)
235 235
236 await checkVideoIsPublished(baseParams, name, uuid, 'absence') 236 await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
237 }) 237 })
238 238
239 it('Should not send a notification if the wait transcoding is false', async function () { 239 it('Should not send a notification if the wait transcoding is false', async function () {
@@ -251,19 +251,19 @@ describe('Test user notifications', function () {
251 it('Should send a notification even if the video is not transcoded in other resolutions', async function () { 251 it('Should send a notification even if the video is not transcoded in other resolutions', async function () {
252 this.timeout(50000) 252 this.timeout(50000)
253 253
254 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true, fixture: 'video_short_240p.mp4' }) 254 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true, fixture: 'video_short_240p.mp4' })
255 await waitJobs(servers) 255 await waitJobs(servers)
256 256
257 await checkVideoIsPublished(baseParams, name, uuid, 'presence') 257 await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
258 }) 258 })
259 259
260 it('Should send a notification with a transcoded video', async function () { 260 it('Should send a notification with a transcoded video', async function () {
261 this.timeout(50000) 261 this.timeout(50000)
262 262
263 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }) 263 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true })
264 await waitJobs(servers) 264 await waitJobs(servers)
265 265
266 await checkVideoIsPublished(baseParams, name, uuid, 'presence') 266 await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
267 }) 267 })
268 268
269 it('Should send a notification when an imported video is transcoded', async function () { 269 it('Should send a notification when an imported video is transcoded', async function () {
@@ -281,7 +281,7 @@ describe('Test user notifications', function () {
281 const { video } = await servers[1].imports.importVideo({ attributes }) 281 const { video } = await servers[1].imports.importVideo({ attributes })
282 282
283 await waitJobs(servers) 283 await waitJobs(servers)
284 await checkVideoIsPublished(baseParams, name, video.uuid, 'presence') 284 await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' })
285 }) 285 })
286 286
287 it('Should send a notification when the scheduled update has been proceeded', async function () { 287 it('Should send a notification when the scheduled update has been proceeded', async function () {
@@ -297,10 +297,10 @@ describe('Test user notifications', function () {
297 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC 297 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
298 } 298 }
299 } 299 }
300 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 300 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data)
301 301
302 await wait(6000) 302 await wait(6000)
303 await checkVideoIsPublished(baseParams, name, uuid, 'presence') 303 await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' })
304 }) 304 })
305 305
306 it('Should not send a notification before the video is published', async function () { 306 it('Should not send a notification before the video is published', async function () {
@@ -315,10 +315,10 @@ describe('Test user notifications', function () {
315 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC 315 privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC
316 } 316 }
317 } 317 }
318 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 318 const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data)
319 319
320 await wait(6000) 320 await wait(6000)
321 await checkVideoIsPublished(baseParams, name, uuid, 'absence') 321 await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' })
322 }) 322 })
323 }) 323 })
324 324
@@ -345,10 +345,12 @@ describe('Test user notifications', function () {
345 privacy: VideoPrivacy.PRIVATE, 345 privacy: VideoPrivacy.PRIVATE,
346 targetUrl: FIXTURE_URLS.badVideo 346 targetUrl: FIXTURE_URLS.badVideo
347 } 347 }
348 const { video } = await servers[0].imports.importVideo({ attributes }) 348 const { video: { shortUUID } } = await servers[0].imports.importVideo({ attributes })
349 349
350 await waitJobs(servers) 350 await waitJobs(servers)
351 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.badVideo, false, 'presence') 351
352 const url = FIXTURE_URLS.badVideo
353 await checkMyVideoImportIsFinished({ ...baseParams, videoName: name, shortUUID, url, success: false, checkType: 'presence' })
352 }) 354 })
353 355
354 it('Should send a notification when the video import succeeded', async function () { 356 it('Should send a notification when the video import succeeded', async function () {
@@ -362,10 +364,12 @@ describe('Test user notifications', function () {
362 privacy: VideoPrivacy.PRIVATE, 364 privacy: VideoPrivacy.PRIVATE,
363 targetUrl: FIXTURE_URLS.goodVideo 365 targetUrl: FIXTURE_URLS.goodVideo
364 } 366 }
365 const { video } = await servers[0].imports.importVideo({ attributes }) 367 const { video: { shortUUID } } = await servers[0].imports.importVideo({ attributes })
366 368
367 await waitJobs(servers) 369 await waitJobs(servers)
368 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.goodVideo, true, 'presence') 370
371 const url = FIXTURE_URLS.goodVideo
372 await checkMyVideoImportIsFinished({ ...baseParams, videoName: name, shortUUID, url, success: true, checkType: 'presence' })
369 }) 373 })
370 }) 374 })
371 375
@@ -404,7 +408,14 @@ describe('Test user notifications', function () {
404 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 408 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
405 await waitJobs(servers) 409 await waitJobs(servers)
406 410
407 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 411 await checkNewActorFollow({
412 ...baseParams,
413 followType: 'channel',
414 followerName: 'root',
415 followerDisplayName: 'super root name',
416 followingDisplayName: myChannelName,
417 checkType: 'presence'
418 })
408 419
409 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 420 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
410 }) 421 })
@@ -415,7 +426,14 @@ describe('Test user notifications', function () {
415 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 426 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
416 await waitJobs(servers) 427 await waitJobs(servers)
417 428
418 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 429 await checkNewActorFollow({
430 ...baseParams,
431 followType: 'channel',
432 followerName: 'root',
433 followerDisplayName: 'super root 2 name',
434 followingDisplayName: myChannelName,
435 checkType: 'presence'
436 })
419 437
420 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 438 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
421 }) 439 })