aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-09 14:27:32 +0100
committerChocobozzz <me@florianbigard.com>2021-12-09 14:27:32 +0100
commit9e847c17f968076287025c798b87506a8d50bb93 (patch)
tree6f1ccb14b80aef31761c1e651a21268f171b40e9
parent650580504cf14a87bd4025eec9673eb5642dc71d (diff)
downloadPeerTube-9e847c17f968076287025c798b87506a8d50bb93.tar.gz
PeerTube-9e847c17f968076287025c798b87506a8d50bb93.tar.zst
PeerTube-9e847c17f968076287025c798b87506a8d50bb93.zip
No notification on moderator abuse
-rw-r--r--server/controllers/api/abuse.ts15
-rw-r--r--server/lib/activitypub/process/process-flag.ts9
-rw-r--r--server/lib/moderation.ts29
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts84
4 files changed, 86 insertions, 51 deletions
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index 72c418e74..a6d0b0512 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -167,7 +167,11 @@ async function reportAbuse (req: express.Request, res: express.Response) {
167 const body: AbuseCreate = req.body 167 const body: AbuseCreate = req.body
168 168
169 const { id } = await sequelizeTypescript.transaction(async t => { 169 const { id } = await sequelizeTypescript.transaction(async t => {
170 const reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) 170 const user = res.locals.oauth.token.User
171 // Don't send abuse notification if reporter is an admin/moderator
172 const skipNotification = user.hasRight(UserRight.MANAGE_ABUSES)
173
174 const reporterAccount = await AccountModel.load(user.Account.id, t)
171 const predefinedReasons = body.predefinedReasons?.map(r => abusePredefinedReasonsMap[r]) 175 const predefinedReasons = body.predefinedReasons?.map(r => abusePredefinedReasonsMap[r])
172 176
173 const baseAbuse = { 177 const baseAbuse = {
@@ -184,7 +188,8 @@ async function reportAbuse (req: express.Request, res: express.Response) {
184 reporterAccount, 188 reporterAccount,
185 transaction: t, 189 transaction: t,
186 startAt: body.video.startAt, 190 startAt: body.video.startAt,
187 endAt: body.video.endAt 191 endAt: body.video.endAt,
192 skipNotification
188 }) 193 })
189 } 194 }
190 195
@@ -193,7 +198,8 @@ async function reportAbuse (req: express.Request, res: express.Response) {
193 baseAbuse, 198 baseAbuse,
194 commentInstance, 199 commentInstance,
195 reporterAccount, 200 reporterAccount,
196 transaction: t 201 transaction: t,
202 skipNotification
197 }) 203 })
198 } 204 }
199 205
@@ -202,7 +208,8 @@ async function reportAbuse (req: express.Request, res: express.Response) {
202 baseAbuse, 208 baseAbuse,
203 accountInstance, 209 accountInstance,
204 reporterAccount, 210 reporterAccount,
205 transaction: t 211 transaction: t,
212 skipNotification
206 }) 213 })
207 }) 214 })
208 215
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts
index 7ed409d0e..fd3e46e2b 100644
--- a/server/lib/activitypub/process/process-flag.ts
+++ b/server/lib/activitypub/process/process-flag.ts
@@ -75,7 +75,8 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc
75 endAt, 75 endAt,
76 reporterAccount, 76 reporterAccount,
77 transaction: t, 77 transaction: t,
78 videoInstance: video 78 videoInstance: video,
79 skipNotification: false
79 }) 80 })
80 } 81 }
81 82
@@ -84,7 +85,8 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc
84 baseAbuse, 85 baseAbuse,
85 reporterAccount, 86 reporterAccount,
86 transaction: t, 87 transaction: t,
87 commentInstance: videoComment 88 commentInstance: videoComment,
89 skipNotification: false
88 }) 90 })
89 } 91 }
90 92
@@ -92,7 +94,8 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc
92 baseAbuse, 94 baseAbuse,
93 reporterAccount, 95 reporterAccount,
94 transaction: t, 96 transaction: t,
95 accountInstance: flaggedAccount 97 accountInstance: flaggedAccount,
98 skipNotification: false
96 }) 99 })
97 }) 100 })
98 } catch (err) { 101 } catch (err) {
diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts
index 456b615b2..c2565f867 100644
--- a/server/lib/moderation.ts
+++ b/server/lib/moderation.ts
@@ -107,8 +107,9 @@ async function createVideoAbuse (options: {
107 endAt: number 107 endAt: number
108 transaction: Transaction 108 transaction: Transaction
109 reporterAccount: MAccountDefault 109 reporterAccount: MAccountDefault
110 skipNotification: boolean
110}) { 111}) {
111 const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount } = options 112 const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount, skipNotification } = options
112 113
113 const associateFun = async (abuseInstance: MAbuseFull) => { 114 const associateFun = async (abuseInstance: MAbuseFull) => {
114 const videoAbuseInstance: MVideoAbuseVideoFull = await VideoAbuseModel.create({ 115 const videoAbuseInstance: MVideoAbuseVideoFull = await VideoAbuseModel.create({
@@ -129,6 +130,7 @@ async function createVideoAbuse (options: {
129 reporterAccount, 130 reporterAccount,
130 flaggedAccount: videoInstance.VideoChannel.Account, 131 flaggedAccount: videoInstance.VideoChannel.Account,
131 transaction, 132 transaction,
133 skipNotification,
132 associateFun 134 associateFun
133 }) 135 })
134} 136}
@@ -138,8 +140,9 @@ function createVideoCommentAbuse (options: {
138 commentInstance: MCommentOwnerVideo 140 commentInstance: MCommentOwnerVideo
139 transaction: Transaction 141 transaction: Transaction
140 reporterAccount: MAccountDefault 142 reporterAccount: MAccountDefault
143 skipNotification: boolean
141}) { 144}) {
142 const { baseAbuse, commentInstance, transaction, reporterAccount } = options 145 const { baseAbuse, commentInstance, transaction, reporterAccount, skipNotification } = options
143 146
144 const associateFun = async (abuseInstance: MAbuseFull) => { 147 const associateFun = async (abuseInstance: MAbuseFull) => {
145 const commentAbuseInstance: MCommentAbuseAccountVideo = await VideoCommentAbuseModel.create({ 148 const commentAbuseInstance: MCommentAbuseAccountVideo = await VideoCommentAbuseModel.create({
@@ -158,6 +161,7 @@ function createVideoCommentAbuse (options: {
158 reporterAccount, 161 reporterAccount,
159 flaggedAccount: commentInstance.Account, 162 flaggedAccount: commentInstance.Account,
160 transaction, 163 transaction,
164 skipNotification,
161 associateFun 165 associateFun
162 }) 166 })
163} 167}
@@ -167,8 +171,9 @@ function createAccountAbuse (options: {
167 accountInstance: MAccountDefault 171 accountInstance: MAccountDefault
168 transaction: Transaction 172 transaction: Transaction
169 reporterAccount: MAccountDefault 173 reporterAccount: MAccountDefault
174 skipNotification: boolean
170}) { 175}) {
171 const { baseAbuse, accountInstance, transaction, reporterAccount } = options 176 const { baseAbuse, accountInstance, transaction, reporterAccount, skipNotification } = options
172 177
173 const associateFun = () => { 178 const associateFun = () => {
174 return Promise.resolve({ isOwned: accountInstance.isOwned() }) 179 return Promise.resolve({ isOwned: accountInstance.isOwned() })
@@ -179,6 +184,7 @@ function createAccountAbuse (options: {
179 reporterAccount, 184 reporterAccount,
180 flaggedAccount: accountInstance, 185 flaggedAccount: accountInstance,
181 transaction, 186 transaction,
187 skipNotification,
182 associateFun 188 associateFun
183 }) 189 })
184} 190}
@@ -207,9 +213,10 @@ async function createAbuse (options: {
207 reporterAccount: MAccountDefault 213 reporterAccount: MAccountDefault
208 flaggedAccount: MAccountLight 214 flaggedAccount: MAccountLight
209 associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} > 215 associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} >
216 skipNotification: boolean
210 transaction: Transaction 217 transaction: Transaction
211}) { 218}) {
212 const { base, reporterAccount, flaggedAccount, associateFun, transaction } = options 219 const { base, reporterAccount, flaggedAccount, associateFun, transaction, skipNotification } = options
213 const auditLogger = auditLoggerFactory('abuse') 220 const auditLogger = auditLoggerFactory('abuse')
214 221
215 const abuseAttributes = Object.assign({}, base, { flaggedAccountId: flaggedAccount.id }) 222 const abuseAttributes = Object.assign({}, base, { flaggedAccountId: flaggedAccount.id })
@@ -227,13 +234,15 @@ async function createAbuse (options: {
227 const abuseJSON = abuseInstance.toFormattedAdminJSON() 234 const abuseJSON = abuseInstance.toFormattedAdminJSON()
228 auditLogger.create(reporterAccount.Actor.getIdentifier(), new AbuseAuditView(abuseJSON)) 235 auditLogger.create(reporterAccount.Actor.getIdentifier(), new AbuseAuditView(abuseJSON))
229 236
230 afterCommitIfTransaction(transaction, () => { 237 if (!skipNotification) {
231 Notifier.Instance.notifyOnNewAbuse({ 238 afterCommitIfTransaction(transaction, () => {
232 abuse: abuseJSON, 239 Notifier.Instance.notifyOnNewAbuse({
233 abuseInstance, 240 abuse: abuseJSON,
234 reporter: reporterAccount.Actor.getIdentifier() 241 abuseInstance,
242 reporter: reporterAccount.Actor.getIdentifier()
243 })
235 }) 244 })
236 }) 245 }
237 246
238 logger.info('Abuse report %d created.', abuseInstance.id) 247 logger.info('Abuse report %d created.', abuseInstance.id)
239 248
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index f806fed31..81ce8061b 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -24,11 +24,13 @@ import {
24 wait, 24 wait,
25 waitJobs 25 waitJobs
26} from '@shared/extra-utils' 26} from '@shared/extra-utils'
27import { AbuseState, CustomConfig, UserNotification, VideoPrivacy } from '@shared/models' 27import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models'
28 28
29describe('Test moderation notifications', function () { 29describe('Test moderation notifications', function () {
30 let servers: PeerTubeServer[] = [] 30 let servers: PeerTubeServer[] = []
31 let userAccessToken: string 31 let userToken1: string
32 let userToken2: string
33
32 let userNotifications: UserNotification[] = [] 34 let userNotifications: UserNotification[] = []
33 let adminNotifications: UserNotification[] = [] 35 let adminNotifications: UserNotification[] = []
34 let adminNotificationsServer2: UserNotification[] = [] 36 let adminNotificationsServer2: UserNotification[] = []
@@ -39,11 +41,13 @@ describe('Test moderation notifications', function () {
39 41
40 const res = await prepareNotificationsTest(3) 42 const res = await prepareNotificationsTest(3)
41 emails = res.emails 43 emails = res.emails
42 userAccessToken = res.userAccessToken 44 userToken1 = res.userAccessToken
43 servers = res.servers 45 servers = res.servers
44 userNotifications = res.userNotifications 46 userNotifications = res.userNotifications
45 adminNotifications = res.adminNotifications 47 adminNotifications = res.adminNotifications
46 adminNotificationsServer2 = res.adminNotificationsServer2 48 adminNotificationsServer2 = res.adminNotificationsServer2
49
50 userToken2 = await servers[1].users.generateUserAndToken('user2', UserRole.USER)
47 }) 51 })
48 52
49 describe('Abuse for moderators notification', function () { 53 describe('Abuse for moderators notification', function () {
@@ -58,15 +62,27 @@ describe('Test moderation notifications', function () {
58 } 62 }
59 }) 63 })
60 64
61 it('Should send a notification to moderators on local video abuse', async function () { 65 it('Should not send a notification to moderators on local abuse reported by an admin', async function () {
62 this.timeout(20000) 66 this.timeout(20000)
63 67
64 const name = 'video for abuse ' + buildUUID() 68 const name = 'video for abuse ' + buildUUID()
65 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 69 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
66 70
67 await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }) 71 await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' })
68 72
69 await waitJobs(servers) 73 await waitJobs(servers)
74 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'absence' })
75 })
76
77 it('Should send a notification to moderators on local video abuse', async function () {
78 this.timeout(20000)
79
80 const name = 'video for abuse ' + buildUUID()
81 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
82
83 await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' })
84
85 await waitJobs(servers)
70 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) 86 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
71 }) 87 })
72 88
@@ -74,12 +90,12 @@ describe('Test moderation notifications', function () {
74 this.timeout(20000) 90 this.timeout(20000)
75 91
76 const name = 'video for abuse ' + buildUUID() 92 const name = 'video for abuse ' + buildUUID()
77 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 93 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
78 94
79 await waitJobs(servers) 95 await waitJobs(servers)
80 96
81 const videoId = await servers[1].videos.getId({ uuid: video.uuid }) 97 const videoId = await servers[1].videos.getId({ uuid: video.uuid })
82 await servers[1].abuses.report({ videoId, reason: 'super reason' }) 98 await servers[1].abuses.report({ token: userToken2, videoId, reason: 'super reason' })
83 99
84 await waitJobs(servers) 100 await waitJobs(servers)
85 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) 101 await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
@@ -89,16 +105,16 @@ describe('Test moderation notifications', function () {
89 this.timeout(20000) 105 this.timeout(20000)
90 106
91 const name = 'video for abuse ' + buildUUID() 107 const name = 'video for abuse ' + buildUUID()
92 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 108 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
93 const comment = await servers[0].comments.createThread({ 109 const comment = await servers[0].comments.createThread({
94 token: userAccessToken, 110 token: userToken1,
95 videoId: video.id, 111 videoId: video.id,
96 text: 'comment abuse ' + buildUUID() 112 text: 'comment abuse ' + buildUUID()
97 }) 113 })
98 114
99 await waitJobs(servers) 115 await waitJobs(servers)
100 116
101 await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' }) 117 await servers[0].abuses.report({ token: userToken1, commentId: comment.id, reason: 'super reason' })
102 118
103 await waitJobs(servers) 119 await waitJobs(servers)
104 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) 120 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
@@ -108,10 +124,10 @@ describe('Test moderation notifications', function () {
108 this.timeout(20000) 124 this.timeout(20000)
109 125
110 const name = 'video for abuse ' + buildUUID() 126 const name = 'video for abuse ' + buildUUID()
111 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 127 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
112 128
113 await servers[0].comments.createThread({ 129 await servers[0].comments.createThread({
114 token: userAccessToken, 130 token: userToken1,
115 videoId: video.id, 131 videoId: video.id,
116 text: 'comment abuse ' + buildUUID() 132 text: 'comment abuse ' + buildUUID()
117 }) 133 })
@@ -120,7 +136,7 @@ describe('Test moderation notifications', function () {
120 136
121 const { data } = await servers[1].comments.listThreads({ videoId: video.uuid }) 137 const { data } = await servers[1].comments.listThreads({ videoId: video.uuid })
122 const commentId = data[0].id 138 const commentId = data[0].id
123 await servers[1].abuses.report({ commentId, reason: 'super reason' }) 139 await servers[1].abuses.report({ token: userToken2, commentId, reason: 'super reason' })
124 140
125 await waitJobs(servers) 141 await waitJobs(servers)
126 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) 142 await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' })
@@ -133,7 +149,7 @@ describe('Test moderation notifications', function () {
133 const { account } = await servers[0].users.create({ username, password: 'donald' }) 149 const { account } = await servers[0].users.create({ username, password: 'donald' })
134 const accountId = account.id 150 const accountId = account.id
135 151
136 await servers[0].abuses.report({ accountId, reason: 'super reason' }) 152 await servers[0].abuses.report({ token: userToken1, accountId, reason: 'super reason' })
137 153
138 await waitJobs(servers) 154 await waitJobs(servers)
139 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) 155 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' })
@@ -149,7 +165,7 @@ describe('Test moderation notifications', function () {
149 await waitJobs(servers) 165 await waitJobs(servers)
150 166
151 const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host }) 167 const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host })
152 await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' }) 168 await servers[1].abuses.report({ token: userToken2, accountId: account.id, reason: 'super reason' })
153 169
154 await waitJobs(servers) 170 await waitJobs(servers)
155 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) 171 await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' })
@@ -165,13 +181,13 @@ describe('Test moderation notifications', function () {
165 server: servers[0], 181 server: servers[0],
166 emails, 182 emails,
167 socketNotifications: userNotifications, 183 socketNotifications: userNotifications,
168 token: userAccessToken 184 token: userToken1
169 } 185 }
170 186
171 const name = 'abuse ' + buildUUID() 187 const name = 'abuse ' + buildUUID()
172 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 188 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
173 189
174 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 190 const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' })
175 abuseId = body.abuse.id 191 abuseId = body.abuse.id
176 }) 192 })
177 193
@@ -205,7 +221,7 @@ describe('Test moderation notifications', function () {
205 server: servers[0], 221 server: servers[0],
206 emails, 222 emails,
207 socketNotifications: userNotifications, 223 socketNotifications: userNotifications,
208 token: userAccessToken 224 token: userToken1
209 } 225 }
210 226
211 baseParamsAdmin = { 227 baseParamsAdmin = {
@@ -216,15 +232,15 @@ describe('Test moderation notifications', function () {
216 } 232 }
217 233
218 const name = 'abuse ' + buildUUID() 234 const name = 'abuse ' + buildUUID()
219 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 235 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
220 236
221 { 237 {
222 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 238 const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' })
223 abuseId = body.abuse.id 239 abuseId = body.abuse.id
224 } 240 }
225 241
226 { 242 {
227 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) 243 const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason 2' })
228 abuseId2 = body.abuse.id 244 abuseId2 = body.abuse.id
229 } 245 }
230 }) 246 })
@@ -254,7 +270,7 @@ describe('Test moderation notifications', function () {
254 this.timeout(10000) 270 this.timeout(10000)
255 271
256 const message = 'my super message to moderators' 272 const message = 'my super message to moderators'
257 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 273 await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message })
258 await waitJobs(servers) 274 await waitJobs(servers)
259 275
260 const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com' 276 const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com'
@@ -265,7 +281,7 @@ describe('Test moderation notifications', function () {
265 this.timeout(10000) 281 this.timeout(10000)
266 282
267 const message = 'my super message that should not be sent to reporter' 283 const message = 'my super message that should not be sent to reporter'
268 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 284 await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message })
269 await waitJobs(servers) 285 await waitJobs(servers)
270 286
271 const toEmail = 'user_1@example.com' 287 const toEmail = 'user_1@example.com'
@@ -281,7 +297,7 @@ describe('Test moderation notifications', function () {
281 server: servers[0], 297 server: servers[0],
282 emails, 298 emails,
283 socketNotifications: userNotifications, 299 socketNotifications: userNotifications,
284 token: userAccessToken 300 token: userToken1
285 } 301 }
286 }) 302 })
287 303
@@ -289,7 +305,7 @@ describe('Test moderation notifications', function () {
289 this.timeout(10000) 305 this.timeout(10000)
290 306
291 const name = 'video for abuse ' + buildUUID() 307 const name = 'video for abuse ' + buildUUID()
292 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 308 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
293 309
294 await servers[0].blacklist.add({ videoId: uuid }) 310 await servers[0].blacklist.add({ videoId: uuid })
295 311
@@ -301,7 +317,7 @@ describe('Test moderation notifications', function () {
301 this.timeout(10000) 317 this.timeout(10000)
302 318
303 const name = 'video for abuse ' + buildUUID() 319 const name = 'video for abuse ' + buildUUID()
304 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) 320 const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } })
305 321
306 await servers[0].blacklist.add({ videoId: uuid }) 322 await servers[0].blacklist.add({ videoId: uuid })
307 323
@@ -335,7 +351,7 @@ describe('Test moderation notifications', function () {
335 351
336 await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' }) 352 await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' })
337 353
338 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 354 const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } }
339 await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' }) 355 await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' })
340 }) 356 })
341 }) 357 })
@@ -377,7 +393,7 @@ describe('Test moderation notifications', function () {
377 393
378 await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' }) 394 await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' })
379 395
380 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 396 const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } }
381 await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' }) 397 await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' })
382 }) 398 })
383 399
@@ -404,7 +420,7 @@ describe('Test moderation notifications', function () {
404 const followingHost = servers[2].host 420 const followingHost = servers[2].host
405 await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' }) 421 await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' })
406 422
407 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 423 const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } }
408 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' }) 424 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' })
409 425
410 config.followings.instance.autoFollowBack.enabled = false 426 config.followings.instance.autoFollowBack.enabled = false
@@ -461,7 +477,7 @@ describe('Test moderation notifications', function () {
461 server: servers[0], 477 server: servers[0],
462 emails, 478 emails,
463 socketNotifications: userNotifications, 479 socketNotifications: userNotifications,
464 token: userAccessToken 480 token: userToken1
465 } 481 }
466 482
467 currentCustomConfig = await servers[0].config.getCustomConfig() 483 currentCustomConfig = await servers[0].config.getCustomConfig()
@@ -490,7 +506,7 @@ describe('Test moderation notifications', function () {
490 this.timeout(120000) 506 this.timeout(120000)
491 507
492 videoName = 'video with auto-blacklist ' + buildUUID() 508 videoName = 'video with auto-blacklist ' + buildUUID()
493 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } }) 509 const video = await servers[0].videos.upload({ token: userToken1, attributes: { name: videoName } })
494 shortUUID = video.shortUUID 510 shortUUID = video.shortUUID
495 uuid = video.uuid 511 uuid = video.uuid
496 512
@@ -547,7 +563,7 @@ describe('Test moderation notifications', function () {
547 } 563 }
548 } 564 }
549 565
550 const { shortUUID, uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes }) 566 const { shortUUID, uuid } = await servers[0].videos.upload({ token: userToken1, attributes })
551 567
552 await servers[0].blacklist.remove({ videoId: uuid }) 568 await servers[0].blacklist.remove({ videoId: uuid })
553 569
@@ -579,7 +595,7 @@ describe('Test moderation notifications', function () {
579 } 595 }
580 } 596 }
581 597
582 const { shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes }) 598 const { shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes })
583 599
584 await wait(6000) 600 await wait(6000)
585 await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' }) 601 await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' })