aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/notifications
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:04:35 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit89d241a79c262b9775c233b73cff080043ebb5e6 (patch)
treecb3b6cb431d25d891ef4e02f66c61d252d17048f /server/tests/api/notifications
parentd23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff)
downloadPeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip
Shorter server command names
Diffstat (limited to 'server/tests/api/notifications')
-rw-r--r--server/tests/api/notifications/admin-notifications.ts12
-rw-r--r--server/tests/api/notifications/comments-notifications.ts92
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts118
-rw-r--r--server/tests/api/notifications/notifications-api.ts42
-rw-r--r--server/tests/api/notifications/user-notifications.ts40
5 files changed, 152 insertions, 152 deletions
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts
index 03fbe0b70..5a5bdb0c8 100644
--- a/server/tests/api/notifications/admin-notifications.ts
+++ b/server/tests/api/notifications/admin-notifications.ts
@@ -58,8 +58,8 @@ describe('Test admin notifications', function () {
58 token: server.accessToken 58 token: server.accessToken
59 } 59 }
60 60
61 await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' }) 61 await server.plugins.install({ npmName: 'peertube-plugin-hello-world' })
62 await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' }) 62 await server.plugins.install({ npmName: 'peertube-theme-background-red' })
63 }) 63 })
64 64
65 describe('Latest PeerTube version notification', function () { 65 describe('Latest PeerTube version notification', function () {
@@ -118,8 +118,8 @@ describe('Test admin notifications', function () {
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 () {
119 this.timeout(30000) 119 this.timeout(30000)
120 120
121 await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') 121 await server.sql.setPluginVersion('hello-world', '0.0.1')
122 await server.sqlCommand.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.PLUGIN, 'hello-world', 'presence')
@@ -140,8 +140,8 @@ describe('Test admin notifications', function () {
140 it('Should send a new notification after a new plugin release', async function () { 140 it('Should send a new notification after a new plugin release', async function () {
141 this.timeout(30000) 141 this.timeout(30000)
142 142
143 await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') 143 await server.sql.setPluginVersion('hello-world', '0.0.1')
144 await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1') 144 await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
145 await wait(6000) 145 await wait(6000)
146 146
147 expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) 147 expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index a74b38e8a..133b6340f 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -52,9 +52,9 @@ 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].videosCommand.upload({ attributes: { name: 'super video' } }) 55 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
56 56
57 const created = await servers[0].commentsCommand.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)
@@ -64,9 +64,9 @@ describe('Test comments notifications', function () {
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].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 67 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
68 68
69 const created = await servers[0].commentsCommand.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)
@@ -76,25 +76,25 @@ describe('Test comments notifications', function () {
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 () {
77 this.timeout(20000) 77 this.timeout(20000)
78 78
79 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) 79 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
80 80
81 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 81 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
82 82
83 const created = await servers[0].commentsCommand.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, uuid, commentId, commentId, 'absence')
88 88
89 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' }) 89 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
90 }) 90 })
91 91
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].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 95 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
96 96
97 const created = await servers[0].commentsCommand.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)
@@ -104,15 +104,15 @@ describe('Test comments notifications', function () {
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].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 107 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
108 108
109 await waitJobs(servers) 109 await waitJobs(servers)
110 110
111 await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 111 await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
112 112
113 await waitJobs(servers) 113 await waitJobs(servers)
114 114
115 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) 115 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
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
@@ -122,11 +122,11 @@ describe('Test comments notifications', function () {
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].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 125 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
126 126
127 const { id: threadId } = await servers[0].commentsCommand.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].commentsCommand.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, uuid, commentId, threadId, 'presence')
@@ -135,22 +135,22 @@ describe('Test comments notifications', function () {
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].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 138 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
139 await waitJobs(servers) 139 await waitJobs(servers)
140 140
141 { 141 {
142 const created = await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 142 const created = await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
143 const threadId = created.id 143 const threadId = created.id
144 await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) 144 await servers[1].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
145 } 145 }
146 146
147 await waitJobs(servers) 147 await waitJobs(servers)
148 148
149 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) 149 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
150 expect(data).to.have.lengthOf(1) 150 expect(data).to.have.lengthOf(1)
151 151
152 const threadId = data[0].id 152 const threadId = data[0].id
153 const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId }) 153 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId })
154 154
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
@@ -161,9 +161,9 @@ describe('Test comments notifications', function () {
161 it('Should convert markdown in comment to html', async function () { 161 it('Should convert markdown in comment to html', async function () {
162 this.timeout(20000) 162 this.timeout(20000)
163 163
164 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'cool video' } }) 164 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'cool video' } })
165 165
166 await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText }) 166 await servers[0].comments.createThread({ videoId: uuid, text: commentText })
167 167
168 await waitJobs(servers) 168 await waitJobs(servers)
169 169
@@ -183,16 +183,16 @@ describe('Test comments notifications', function () {
183 token: userToken 183 token: userToken
184 } 184 }
185 185
186 await servers[0].usersCommand.updateMe({ displayName: 'super root name' }) 186 await servers[0].users.updateMe({ displayName: 'super root name' })
187 await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' }) 187 await servers[1].users.updateMe({ displayName: 'super root 2 name' })
188 }) 188 })
189 189
190 it('Should not send a new mention comment notification if I mention the video owner', async function () { 190 it('Should not send a new mention comment notification if I mention the video owner', async function () {
191 this.timeout(10000) 191 this.timeout(10000)
192 192
193 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 193 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
194 194
195 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 195 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
196 196
197 await waitJobs(servers) 197 await waitJobs(servers)
198 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 198 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -201,9 +201,9 @@ describe('Test comments notifications', function () {
201 it('Should not send a new mention comment notification if I mention myself', async function () { 201 it('Should not send a new mention comment notification if I mention myself', async function () {
202 this.timeout(10000) 202 this.timeout(10000)
203 203
204 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 204 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
205 205
206 const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) 206 const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
207 207
208 await waitJobs(servers) 208 await waitJobs(servers)
209 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 209 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -212,25 +212,25 @@ describe('Test comments notifications', function () {
212 it('Should not send a new mention notification if the account is muted', async function () { 212 it('Should not send a new mention notification if the account is muted', async function () {
213 this.timeout(10000) 213 this.timeout(10000)
214 214
215 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) 215 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
216 216
217 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 217 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
218 218
219 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 219 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
220 220
221 await waitJobs(servers) 221 await waitJobs(servers)
222 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 222 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
223 223
224 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' }) 224 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
225 }) 225 })
226 226
227 it('Should not send a new mention notification if the remote account mention a local account', async function () { 227 it('Should not send a new mention notification if the remote account mention a local account', async function () {
228 this.timeout(20000) 228 this.timeout(20000)
229 229
230 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 230 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
231 231
232 await waitJobs(servers) 232 await waitJobs(servers)
233 const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 233 const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
234 234
235 await waitJobs(servers) 235 await waitJobs(servers)
236 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') 236 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence')
@@ -239,14 +239,14 @@ describe('Test comments notifications', function () {
239 it('Should send a new mention notification after local comments', async function () { 239 it('Should send a new mention notification after local comments', async function () {
240 this.timeout(10000) 240 this.timeout(10000)
241 241
242 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 242 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
243 243
244 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) 244 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
245 245
246 await waitJobs(servers) 246 await waitJobs(servers)
247 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') 247 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
248 248
249 const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }) 249 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
250 250
251 await waitJobs(servers) 251 await waitJobs(servers)
252 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') 252 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
@@ -255,27 +255,27 @@ describe('Test comments notifications', function () {
255 it('Should send a new mention notification after remote comments', async function () { 255 it('Should send a new mention notification after remote comments', async function () {
256 this.timeout(20000) 256 this.timeout(20000)
257 257
258 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 258 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
259 259
260 await waitJobs(servers) 260 await waitJobs(servers)
261 261
262 const text1 = `hello @user_1@localhost:${servers[0].port} 1` 262 const text1 = `hello @user_1@localhost:${servers[0].port} 1`
263 const { id: server2ThreadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: text1 }) 263 const { id: server2ThreadId } = await servers[1].comments.createThread({ videoId: uuid, text: text1 })
264 264
265 await waitJobs(servers) 265 await waitJobs(servers)
266 266
267 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) 267 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
268 expect(data).to.have.lengthOf(1) 268 expect(data).to.have.lengthOf(1)
269 269
270 const server1ThreadId = data[0].id 270 const server1ThreadId = data[0].id
271 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') 271 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
272 272
273 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` 273 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
274 await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) 274 await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
275 275
276 await waitJobs(servers) 276 await waitJobs(servers)
277 277
278 const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId: server1ThreadId }) 278 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId: server1ThreadId })
279 279
280 expect(tree.children).to.have.lengthOf(1) 280 expect(tree.children).to.have.lengthOf(1)
281 const commentId = tree.children[0].comment.id 281 const commentId = tree.children[0].comment.id
@@ -286,11 +286,11 @@ describe('Test comments notifications', function () {
286 it('Should convert markdown in comment to html', async function () { 286 it('Should convert markdown in comment to html', async function () {
287 this.timeout(10000) 287 this.timeout(10000)
288 288
289 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 289 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
290 290
291 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' }) 291 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello 1' })
292 292
293 await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText }) 293 await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
294 294
295 await waitJobs(servers) 295 await waitJobs(servers)
296 296
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 91a2b4fa5..e7c5badd2 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -62,9 +62,9 @@ describe('Test moderation notifications', function () {
62 this.timeout(20000) 62 this.timeout(20000)
63 63
64 const name = 'video for abuse ' + buildUUID() 64 const name = 'video for abuse ' + buildUUID()
65 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 65 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
66 66
67 await servers[0].abusesCommand.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, video.uuid, name, 'presence')
@@ -74,12 +74,12 @@ describe('Test moderation notifications', function () {
74 this.timeout(20000) 74 this.timeout(20000)
75 75
76 const name = 'video for abuse ' + buildUUID() 76 const name = 'video for abuse ' + buildUUID()
77 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 77 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
78 78
79 await waitJobs(servers) 79 await waitJobs(servers)
80 80
81 const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid }) 81 const videoId = await servers[1].videos.getId({ uuid: video.uuid })
82 await servers[1].abusesCommand.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, video.uuid, name, 'presence')
@@ -89,8 +89,8 @@ describe('Test moderation notifications', function () {
89 this.timeout(20000) 89 this.timeout(20000)
90 90
91 const name = 'video for abuse ' + buildUUID() 91 const name = 'video for abuse ' + buildUUID()
92 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 92 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
93 const comment = await servers[0].commentsCommand.createThread({ 93 const comment = await servers[0].comments.createThread({
94 token: userAccessToken, 94 token: userAccessToken,
95 videoId: video.id, 95 videoId: video.id,
96 text: 'comment abuse ' + buildUUID() 96 text: 'comment abuse ' + buildUUID()
@@ -98,7 +98,7 @@ describe('Test moderation notifications', function () {
98 98
99 await waitJobs(servers) 99 await waitJobs(servers)
100 100
101 await servers[0].abusesCommand.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, video.uuid, name, 'presence')
@@ -108,9 +108,9 @@ describe('Test moderation notifications', function () {
108 this.timeout(20000) 108 this.timeout(20000)
109 109
110 const name = 'video for abuse ' + buildUUID() 110 const name = 'video for abuse ' + buildUUID()
111 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 111 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
112 112
113 await servers[0].commentsCommand.createThread({ 113 await servers[0].comments.createThread({
114 token: userAccessToken, 114 token: userAccessToken,
115 videoId: video.id, 115 videoId: video.id,
116 text: 'comment abuse ' + buildUUID() 116 text: 'comment abuse ' + buildUUID()
@@ -118,9 +118,9 @@ describe('Test moderation notifications', function () {
118 118
119 await waitJobs(servers) 119 await waitJobs(servers)
120 120
121 const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid }) 121 const { data } = await servers[1].comments.listThreads({ videoId: video.uuid })
122 const commentId = data[0].id 122 const commentId = data[0].id
123 await servers[1].abusesCommand.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, video.uuid, name, 'presence')
@@ -130,10 +130,10 @@ describe('Test moderation notifications', function () {
130 this.timeout(20000) 130 this.timeout(20000)
131 131
132 const username = 'user' + new Date().getTime() 132 const username = 'user' + new Date().getTime()
133 const { account } = await servers[0].usersCommand.create({ username, password: 'donald' }) 133 const { account } = await servers[0].users.create({ username, password: 'donald' })
134 const accountId = account.id 134 const accountId = account.id
135 135
136 await servers[0].abusesCommand.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, username, 'presence')
@@ -143,13 +143,13 @@ describe('Test moderation notifications', function () {
143 this.timeout(20000) 143 this.timeout(20000)
144 144
145 const username = 'user' + new Date().getTime() 145 const username = 'user' + new Date().getTime()
146 const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) 146 const tmpToken = await servers[0].users.generateUserAndToken(username)
147 await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } }) 147 await servers[0].videos.upload({ token: tmpToken, attributes: { name: 'super video' } })
148 148
149 await waitJobs(servers) 149 await waitJobs(servers)
150 150
151 const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host }) 151 const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host })
152 await servers[1].abusesCommand.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, username, 'presence')
@@ -169,16 +169,16 @@ describe('Test moderation notifications', function () {
169 } 169 }
170 170
171 const name = 'abuse ' + buildUUID() 171 const name = 'abuse ' + buildUUID()
172 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 172 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
173 173
174 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 174 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
175 abuseId = body.abuse.id 175 abuseId = body.abuse.id
176 }) 176 })
177 177
178 it('Should send a notification to reporter if the abuse has been accepted', async function () { 178 it('Should send a notification to reporter if the abuse has been accepted', async function () {
179 this.timeout(10000) 179 this.timeout(10000)
180 180
181 await servers[0].abusesCommand.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, AbuseState.ACCEPTED, 'presence')
@@ -187,7 +187,7 @@ describe('Test moderation notifications', function () {
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 () {
188 this.timeout(10000) 188 this.timeout(10000)
189 189
190 await servers[0].abusesCommand.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, AbuseState.REJECTED, 'presence')
@@ -216,15 +216,15 @@ describe('Test moderation notifications', function () {
216 } 216 }
217 217
218 const name = 'abuse ' + buildUUID() 218 const name = 'abuse ' + buildUUID()
219 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 219 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
220 220
221 { 221 {
222 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 222 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
223 abuseId = body.abuse.id 223 abuseId = body.abuse.id
224 } 224 }
225 225
226 { 226 {
227 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) 227 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
228 abuseId2 = body.abuse.id 228 abuseId2 = body.abuse.id
229 } 229 }
230 }) 230 })
@@ -233,7 +233,7 @@ describe('Test moderation notifications', function () {
233 this.timeout(10000) 233 this.timeout(10000)
234 234
235 const message = 'my super message to users' 235 const message = 'my super message to users'
236 await servers[0].abusesCommand.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, 'user_1@example.com', 'presence')
@@ -243,7 +243,7 @@ describe('Test moderation notifications', function () {
243 this.timeout(10000) 243 this.timeout(10000)
244 244
245 const message = 'my super message that should not be sent to the admin' 245 const message = 'my super message that should not be sent to the admin'
246 await servers[0].abusesCommand.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 await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence')
@@ -253,7 +253,7 @@ describe('Test moderation notifications', function () {
253 this.timeout(10000) 253 this.timeout(10000)
254 254
255 const message = 'my super message to moderators' 255 const message = 'my super message to moderators'
256 await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 256 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
257 await waitJobs(servers) 257 await waitJobs(servers)
258 258
259 await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence') 259 await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence')
@@ -263,7 +263,7 @@ describe('Test moderation notifications', function () {
263 this.timeout(10000) 263 this.timeout(10000)
264 264
265 const message = 'my super message that should not be sent to reporter' 265 const message = 'my super message that should not be sent to reporter'
266 await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 266 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
267 await waitJobs(servers) 267 await waitJobs(servers)
268 268
269 await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence') 269 await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence')
@@ -286,9 +286,9 @@ describe('Test moderation notifications', function () {
286 this.timeout(10000) 286 this.timeout(10000)
287 287
288 const name = 'video for abuse ' + buildUUID() 288 const name = 'video for abuse ' + buildUUID()
289 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 289 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
290 290
291 await servers[0].blacklistCommand.add({ videoId: uuid }) 291 await servers[0].blacklist.add({ videoId: uuid })
292 292
293 await waitJobs(servers) 293 await waitJobs(servers)
294 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist') 294 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
@@ -298,12 +298,12 @@ describe('Test moderation notifications', function () {
298 this.timeout(10000) 298 this.timeout(10000)
299 299
300 const name = 'video for abuse ' + buildUUID() 300 const name = 'video for abuse ' + buildUUID()
301 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 301 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
302 302
303 await servers[0].blacklistCommand.add({ videoId: uuid }) 303 await servers[0].blacklist.add({ videoId: uuid })
304 304
305 await waitJobs(servers) 305 await waitJobs(servers)
306 await servers[0].blacklistCommand.remove({ videoId: uuid }) 306 await servers[0].blacklist.remove({ videoId: uuid })
307 await waitJobs(servers) 307 await waitJobs(servers)
308 308
309 await wait(500) 309 await wait(500)
@@ -326,7 +326,7 @@ describe('Test moderation notifications', function () {
326 it('Should send a notification only to moderators when a user registers on the instance', async function () { 326 it('Should send a notification only to moderators when a user registers on the instance', async function () {
327 this.timeout(10000) 327 this.timeout(10000)
328 328
329 await servers[0].usersCommand.register({ username: 'user_45' }) 329 await servers[0].users.register({ username: 'user_45' })
330 330
331 await waitJobs(servers) 331 await waitJobs(servers)
332 332
@@ -368,7 +368,7 @@ describe('Test moderation notifications', function () {
368 it('Should send a notification only to admin when there is a new instance follower', async function () { 368 it('Should send a notification only to admin when there is a new instance follower', async function () {
369 this.timeout(20000) 369 this.timeout(20000)
370 370
371 await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) 371 await servers[2].follows.follow({ targets: [ servers[0].url ] })
372 372
373 await waitJobs(servers) 373 await waitJobs(servers)
374 374
@@ -381,7 +381,7 @@ describe('Test moderation notifications', function () {
381 it('Should send a notification on auto follow back', async function () { 381 it('Should send a notification on auto follow back', async function () {
382 this.timeout(40000) 382 this.timeout(40000)
383 383
384 await servers[2].followsCommand.unfollow({ target: servers[0] }) 384 await servers[2].follows.unfollow({ target: servers[0] })
385 await waitJobs(servers) 385 await waitJobs(servers)
386 386
387 const config = { 387 const config = {
@@ -391,9 +391,9 @@ describe('Test moderation notifications', function () {
391 } 391 }
392 } 392 }
393 } 393 }
394 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 394 await servers[0].config.updateCustomSubConfig({ newConfig: config })
395 395
396 await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) 396 await servers[2].follows.follow({ targets: [ servers[0].url ] })
397 397
398 await waitJobs(servers) 398 await waitJobs(servers)
399 399
@@ -405,16 +405,16 @@ describe('Test moderation notifications', function () {
405 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence') 405 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
406 406
407 config.followings.instance.autoFollowBack.enabled = false 407 config.followings.instance.autoFollowBack.enabled = false
408 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 408 await servers[0].config.updateCustomSubConfig({ newConfig: config })
409 await servers[0].followsCommand.unfollow({ target: servers[2] }) 409 await servers[0].follows.unfollow({ target: servers[2] })
410 await servers[2].followsCommand.unfollow({ target: servers[0] }) 410 await servers[2].follows.unfollow({ target: servers[0] })
411 }) 411 })
412 412
413 it('Should send a notification on auto instances index follow', async function () { 413 it('Should send a notification on auto instances index follow', async function () {
414 this.timeout(30000) 414 this.timeout(30000)
415 await servers[0].followsCommand.unfollow({ target: servers[1] }) 415 await servers[0].follows.unfollow({ target: servers[1] })
416 416
417 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 417 await servers[0].config.updateCustomSubConfig({ newConfig: config })
418 418
419 await wait(5000) 419 await wait(5000)
420 await waitJobs(servers) 420 await waitJobs(servers)
@@ -424,8 +424,8 @@ describe('Test moderation notifications', function () {
424 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') 424 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
425 425
426 config.followings.instance.autoFollowIndex.enabled = false 426 config.followings.instance.autoFollowIndex.enabled = false
427 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 427 await servers[0].config.updateCustomSubConfig({ newConfig: config })
428 await servers[0].followsCommand.unfollow({ target: servers[1] }) 428 await servers[0].follows.unfollow({ target: servers[1] })
429 }) 429 })
430 }) 430 })
431 431
@@ -460,7 +460,7 @@ describe('Test moderation notifications', function () {
460 token: userAccessToken 460 token: userAccessToken
461 } 461 }
462 462
463 currentCustomConfig = await servers[0].configCommand.getCustomConfig() 463 currentCustomConfig = await servers[0].config.getCustomConfig()
464 464
465 const autoBlacklistTestsCustomConfig = { 465 const autoBlacklistTestsCustomConfig = {
466 ...currentCustomConfig, 466 ...currentCustomConfig,
@@ -476,10 +476,10 @@ describe('Test moderation notifications', function () {
476 476
477 // enable transcoding otherwise own publish notification after transcoding not expected 477 // enable transcoding otherwise own publish notification after transcoding not expected
478 autoBlacklistTestsCustomConfig.transcoding.enabled = true 478 autoBlacklistTestsCustomConfig.transcoding.enabled = true
479 await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) 479 await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
480 480
481 await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 481 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
482 await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 482 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
483 483
484 }) 484 })
485 485
@@ -487,7 +487,7 @@ describe('Test moderation notifications', function () {
487 this.timeout(40000) 487 this.timeout(40000)
488 488
489 videoName = 'video with auto-blacklist ' + buildUUID() 489 videoName = 'video with auto-blacklist ' + buildUUID()
490 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } }) 490 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } })
491 videoUUID = uuid 491 videoUUID = uuid
492 492
493 await waitJobs(servers) 493 await waitJobs(servers)
@@ -509,7 +509,7 @@ describe('Test moderation notifications', function () {
509 it('Should send video published and unblacklist after video unblacklisted', async function () { 509 it('Should send video published and unblacklist after video unblacklisted', async function () {
510 this.timeout(40000) 510 this.timeout(40000)
511 511
512 await servers[0].blacklistCommand.remove({ videoId: videoUUID }) 512 await servers[0].blacklist.remove({ videoId: videoUUID })
513 513
514 await waitJobs(servers) 514 await waitJobs(servers)
515 515
@@ -543,9 +543,9 @@ describe('Test moderation notifications', function () {
543 } 543 }
544 } 544 }
545 545
546 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 546 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
547 547
548 await servers[0].blacklistCommand.remove({ videoId: uuid }) 548 await servers[0].blacklist.remove({ videoId: uuid })
549 549
550 await waitJobs(servers) 550 await waitJobs(servers)
551 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist') 551 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
@@ -575,7 +575,7 @@ describe('Test moderation notifications', function () {
575 } 575 }
576 } 576 }
577 577
578 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 578 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
579 579
580 await wait(6000) 580 await wait(6000)
581 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') 581 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
@@ -589,17 +589,17 @@ describe('Test moderation notifications', function () {
589 const name = 'video without auto-blacklist ' + buildUUID() 589 const name = 'video without auto-blacklist ' + buildUUID()
590 590
591 // admin with blacklist right will not be auto-blacklisted 591 // admin with blacklist right will not be auto-blacklisted
592 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } }) 592 const { uuid } = await servers[0].videos.upload({ attributes: { name } })
593 593
594 await waitJobs(servers) 594 await waitJobs(servers)
595 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') 595 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence')
596 }) 596 })
597 597
598 after(async () => { 598 after(async () => {
599 await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) 599 await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig })
600 600
601 await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 601 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
602 await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 602 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
603 }) 603 })
604 }) 604 })
605 605
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index 41e1b8015..647d783b5 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -31,10 +31,10 @@ describe('Test notifications API', function () {
31 userNotifications = res.userNotifications 31 userNotifications = res.userNotifications
32 server = res.servers[0] 32 server = res.servers[0]
33 33
34 await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port }) 34 await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
35 35
36 for (let i = 0; i < 10; i++) { 36 for (let i = 0; i < 10; i++) {
37 await server.videosCommand.randomUpload({ wait: false }) 37 await server.videos.randomUpload({ wait: false })
38 } 38 }
39 39
40 await waitJobs([ server ]) 40 await waitJobs([ server ])
@@ -43,14 +43,14 @@ describe('Test notifications API', function () {
43 describe('Mark as read', function () { 43 describe('Mark as read', function () {
44 44
45 it('Should mark as read some notifications', async function () { 45 it('Should mark as read some notifications', async function () {
46 const { data } = await server.notificationsCommand.list({ token: userToken, start: 2, count: 3 }) 46 const { data } = await server.notifications.list({ token: userToken, start: 2, count: 3 })
47 const ids = data.map(n => n.id) 47 const ids = data.map(n => n.id)
48 48
49 await server.notificationsCommand.markAsRead({ token: userToken, ids }) 49 await server.notifications.markAsRead({ token: userToken, ids })
50 }) 50 })
51 51
52 it('Should have the notifications marked as read', async function () { 52 it('Should have the notifications marked as read', async function () {
53 const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10 }) 53 const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10 })
54 54
55 expect(data[0].read).to.be.false 55 expect(data[0].read).to.be.false
56 expect(data[1].read).to.be.false 56 expect(data[1].read).to.be.false
@@ -61,7 +61,7 @@ describe('Test notifications API', function () {
61 }) 61 })
62 62
63 it('Should only list read notifications', async function () { 63 it('Should only list read notifications', async function () {
64 const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: false }) 64 const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: false })
65 65
66 for (const notification of data) { 66 for (const notification of data) {
67 expect(notification.read).to.be.true 67 expect(notification.read).to.be.true
@@ -69,7 +69,7 @@ describe('Test notifications API', function () {
69 }) 69 })
70 70
71 it('Should only list unread notifications', async function () { 71 it('Should only list unread notifications', async function () {
72 const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true }) 72 const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
73 73
74 for (const notification of data) { 74 for (const notification of data) {
75 expect(notification.read).to.be.false 75 expect(notification.read).to.be.false
@@ -77,9 +77,9 @@ describe('Test notifications API', function () {
77 }) 77 })
78 78
79 it('Should mark as read all notifications', async function () { 79 it('Should mark as read all notifications', async function () {
80 await server.notificationsCommand.markAsReadAll({ token: userToken }) 80 await server.notifications.markAsReadAll({ token: userToken })
81 81
82 const body = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true }) 82 const body = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
83 83
84 expect(body.total).to.equal(0) 84 expect(body.total).to.equal(0)
85 expect(body.data).to.have.lengthOf(0) 85 expect(body.data).to.have.lengthOf(0)
@@ -101,17 +101,17 @@ describe('Test notifications API', function () {
101 it('Should not have notifications', async function () { 101 it('Should not have notifications', async function () {
102 this.timeout(20000) 102 this.timeout(20000)
103 103
104 await server.notificationsCommand.updateMySettings({ 104 await server.notifications.updateMySettings({
105 token: userToken, 105 token: userToken,
106 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE } 106 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE }
107 }) 107 })
108 108
109 { 109 {
110 const info = await server.usersCommand.getMyInfo({ token: userToken }) 110 const info = await server.users.getMyInfo({ token: userToken })
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.videosCommand.randomUpload() 114 const { name, uuid } = 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 }, name, uuid, 'absence')
@@ -120,17 +120,17 @@ describe('Test notifications API', function () {
120 it('Should only have web notifications', async function () { 120 it('Should only have web notifications', async function () {
121 this.timeout(20000) 121 this.timeout(20000)
122 122
123 await server.notificationsCommand.updateMySettings({ 123 await server.notifications.updateMySettings({
124 token: userToken, 124 token: userToken,
125 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB } 125 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB }
126 }) 126 })
127 127
128 { 128 {
129 const info = await server.usersCommand.getMyInfo({ token: userToken }) 129 const info = await server.users.getMyInfo({ token: userToken })
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.videosCommand.randomUpload() 133 const { name, uuid } = await server.videos.randomUpload()
134 134
135 { 135 {
136 const check = { mail: true, web: false } 136 const check = { mail: true, web: false }
@@ -146,17 +146,17 @@ describe('Test notifications API', function () {
146 it('Should only have mail notifications', async function () { 146 it('Should only have mail notifications', async function () {
147 this.timeout(20000) 147 this.timeout(20000)
148 148
149 await server.notificationsCommand.updateMySettings({ 149 await server.notifications.updateMySettings({
150 token: userToken, 150 token: userToken,
151 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL } 151 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL }
152 }) 152 })
153 153
154 { 154 {
155 const info = await server.usersCommand.getMyInfo({ token: userToken }) 155 const info = await server.users.getMyInfo({ token: userToken })
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.videosCommand.randomUpload() 159 const { name, uuid } = await server.videos.randomUpload()
160 160
161 { 161 {
162 const check = { mail: false, web: true } 162 const check = { mail: false, web: true }
@@ -172,7 +172,7 @@ describe('Test notifications API', function () {
172 it('Should have email and web notifications', async function () { 172 it('Should have email and web notifications', async function () {
173 this.timeout(20000) 173 this.timeout(20000)
174 174
175 await server.notificationsCommand.updateMySettings({ 175 await server.notifications.updateMySettings({
176 token: userToken, 176 token: userToken,
177 settings: { 177 settings: {
178 ...getAllNotificationsSettings(), 178 ...getAllNotificationsSettings(),
@@ -181,13 +181,13 @@ describe('Test notifications API', function () {
181 }) 181 })
182 182
183 { 183 {
184 const info = await server.usersCommand.getMyInfo({ token: userToken }) 184 const info = await server.users.getMyInfo({ token: userToken })
185 expect(info.notificationSettings.newVideoFromSubscription).to.equal( 185 expect(info.notificationSettings.newVideoFromSubscription).to.equal(
186 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL 186 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
187 ) 187 )
188 } 188 }
189 189
190 const { name, uuid } = await server.videosCommand.randomUpload() 190 const { name, uuid } = await server.videos.randomUpload()
191 191
192 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 192 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
193 }) 193 })
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 4db8c1576..53f8c7594 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -61,7 +61,7 @@ describe('Test user notifications', function () {
61 61
62 await uploadRandomVideoOnServers(servers, 1) 62 await uploadRandomVideoOnServers(servers, 1)
63 63
64 const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken }) 64 const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
65 expect(notification).to.be.undefined 65 expect(notification).to.be.undefined
66 66
67 expect(emails).to.have.lengthOf(0) 67 expect(emails).to.have.lengthOf(0)
@@ -71,7 +71,7 @@ describe('Test user notifications', function () {
71 it('Should send a new video notification if the user follows the local video publisher', async function () { 71 it('Should send a new video notification if the user follows the local video publisher', async function () {
72 this.timeout(15000) 72 this.timeout(15000)
73 73
74 await servers[0].subscriptionsCommand.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, uuid } = await uploadRandomVideoOnServers(servers, 1)
@@ -81,7 +81,7 @@ describe('Test user notifications', function () {
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 () {
82 this.timeout(150000) // Server 2 has transcoding enabled 82 this.timeout(150000) // Server 2 has transcoding enabled
83 83
84 await servers[0].subscriptionsCommand.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, uuid } = await uploadRandomVideoOnServers(servers, 2)
@@ -153,7 +153,7 @@ describe('Test user notifications', function () {
153 153
154 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 154 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
155 155
156 await servers[0].videosCommand.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, name, uuid, 'presence')
@@ -167,7 +167,7 @@ describe('Test user notifications', function () {
167 167
168 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 168 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
169 169
170 await servers[1].videosCommand.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, name, uuid, 'presence')
@@ -179,7 +179,7 @@ describe('Test user notifications', function () {
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 } = await uploadRandomVideoOnServers(servers, 1, data)
181 181
182 await servers[0].videosCommand.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, name, uuid, 'absence')
185 }) 185 })
@@ -190,7 +190,7 @@ describe('Test user notifications', function () {
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 } = await uploadRandomVideoOnServers(servers, 2, data)
192 192
193 await servers[1].videosCommand.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, name, uuid, 'absence')
@@ -207,7 +207,7 @@ describe('Test user notifications', function () {
207 privacy: VideoPrivacy.PUBLIC, 207 privacy: VideoPrivacy.PUBLIC,
208 targetUrl: ImportsCommand.getGoodVideoUrl() 208 targetUrl: ImportsCommand.getGoodVideoUrl()
209 } 209 }
210 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 210 const { video } = await servers[0].imports.importVideo({ attributes })
211 211
212 await waitJobs(servers) 212 await waitJobs(servers)
213 213
@@ -242,7 +242,7 @@ describe('Test user notifications', function () {
242 await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false }) 242 await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false })
243 await waitJobs(servers) 243 await waitJobs(servers)
244 244
245 const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken }) 245 const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
246 if (notification) { 246 if (notification) {
247 expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED) 247 expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED)
248 } 248 }
@@ -278,7 +278,7 @@ describe('Test user notifications', function () {
278 targetUrl: ImportsCommand.getGoodVideoUrl(), 278 targetUrl: ImportsCommand.getGoodVideoUrl(),
279 waitTranscoding: true 279 waitTranscoding: true
280 } 280 }
281 const { video } = await servers[1].importsCommand.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, name, video.uuid, 'presence')
@@ -345,7 +345,7 @@ describe('Test user notifications', function () {
345 privacy: VideoPrivacy.PRIVATE, 345 privacy: VideoPrivacy.PRIVATE,
346 targetUrl: ImportsCommand.getBadVideoUrl() 346 targetUrl: ImportsCommand.getBadVideoUrl()
347 } 347 }
348 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 348 const { video } = await servers[0].imports.importVideo({ attributes })
349 349
350 await waitJobs(servers) 350 await waitJobs(servers)
351 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence') 351 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
@@ -362,7 +362,7 @@ describe('Test user notifications', function () {
362 privacy: VideoPrivacy.PRIVATE, 362 privacy: VideoPrivacy.PRIVATE,
363 targetUrl: ImportsCommand.getGoodVideoUrl() 363 targetUrl: ImportsCommand.getGoodVideoUrl()
364 } 364 }
365 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 365 const { video } = await servers[0].imports.importVideo({ attributes })
366 366
367 await waitJobs(servers) 367 await waitJobs(servers)
368 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence') 368 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
@@ -382,16 +382,16 @@ describe('Test user notifications', function () {
382 token: userAccessToken 382 token: userAccessToken
383 } 383 }
384 384
385 await servers[0].usersCommand.updateMe({ displayName: 'super root name' }) 385 await servers[0].users.updateMe({ displayName: 'super root name' })
386 386
387 await servers[0].usersCommand.updateMe({ 387 await servers[0].users.updateMe({
388 token: userAccessToken, 388 token: userAccessToken,
389 displayName: myUserName 389 displayName: myUserName
390 }) 390 })
391 391
392 await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' }) 392 await servers[1].users.updateMe({ displayName: 'super root 2 name' })
393 393
394 await servers[0].channelsCommand.update({ 394 await servers[0].channels.update({
395 token: userAccessToken, 395 token: userAccessToken,
396 channelName: 'user_1_channel', 396 channelName: 'user_1_channel',
397 attributes: { displayName: myChannelName } 397 attributes: { displayName: myChannelName }
@@ -401,23 +401,23 @@ describe('Test user notifications', function () {
401 it('Should notify when a local channel is following one of our channel', async function () { 401 it('Should notify when a local channel is following one of our channel', async function () {
402 this.timeout(50000) 402 this.timeout(50000)
403 403
404 await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 404 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
405 await waitJobs(servers) 405 await waitJobs(servers)
406 406
407 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 407 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
408 408
409 await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 409 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
410 }) 410 })
411 411
412 it('Should notify when a remote channel is following one of our channel', async function () { 412 it('Should notify when a remote channel is following one of our channel', async function () {
413 this.timeout(50000) 413 this.timeout(50000)
414 414
415 await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 415 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
416 await waitJobs(servers) 416 await waitJobs(servers)
417 417
418 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 418 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
419 419
420 await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 420 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
421 }) 421 })
422 422
423 // PeerTube does not support accout -> account follows 423 // PeerTube does not support accout -> account follows