aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/users/user-notifications.ts
diff options
context:
space:
mode:
authorJosh Morel <morel.josh@hotmail.com>2019-04-02 05:26:47 -0400
committerChocobozzz <chocobozzz@cpy.re>2019-04-02 11:26:47 +0200
commit7ccddd7b5250bd25a917a6e77e58b87b9484a2a4 (patch)
treee75dc991369c1768804fefa114eb2a832881087f /shared/utils/users/user-notifications.ts
parent12fed49ebab0c414713d57ea316b6488ae6bef99 (diff)
downloadPeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.gz
PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.tar.zst
PeerTube-7ccddd7b5250bd25a917a6e77e58b87b9484a2a4.zip
add quarantine videos feature (#1637)
* add quarantine videos feature * increase Notification settings test timeout to 20000ms. was completing 7000 locally but timing out after 10000 on travis * fix quarantine video test issues -propagate misspelling -remove skip from server/tests/client.ts * WIP use blacklist for moderator video approval instead of video.quarantine boolean * finish auto-blacklist feature
Diffstat (limited to 'shared/utils/users/user-notifications.ts')
-rw-r--r--shared/utils/users/user-notifications.ts35
1 files changed, 32 insertions, 3 deletions
diff --git a/shared/utils/users/user-notifications.ts b/shared/utils/users/user-notifications.ts
index c8ed7df30..e3a79f523 100644
--- a/shared/utils/users/user-notifications.ts
+++ b/shared/utils/users/user-notifications.ts
@@ -18,7 +18,7 @@ function updateMyNotificationSettings (url: string, token: string, settings: Use
18 }) 18 })
19} 19}
20 20
21function getUserNotifications ( 21async function getUserNotifications (
22 url: string, 22 url: string,
23 token: string, 23 token: string,
24 start: number, 24 start: number,
@@ -165,12 +165,15 @@ async function checkNewVideoFromSubscription (base: CheckerBaseParams, videoName
165 checkVideo(notification.video, videoName, videoUUID) 165 checkVideo(notification.video, videoName, videoUUID)
166 checkActor(notification.video.channel) 166 checkActor(notification.video.channel)
167 } else { 167 } else {
168 expect(notification.video).to.satisfy(v => v === undefined || v.name !== videoName) 168 expect(notification).to.satisfy((n: UserNotification) => {
169 return n === undefined || n.type !== UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION || n.video.name !== videoName
170 })
169 } 171 }
170 } 172 }
171 173
172 function emailFinder (email: object) { 174 function emailFinder (email: object) {
173 return email[ 'text' ].indexOf(videoUUID) !== -1 175 const text = email[ 'text' ]
176 return text.indexOf(videoUUID) !== -1 && text.indexOf('Your subscription') !== -1
174 } 177 }
175 178
176 await checkNotification(base, notificationChecker, emailFinder, type) 179 await checkNotification(base, notificationChecker, emailFinder, type)
@@ -387,6 +390,31 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU
387 await checkNotification(base, notificationChecker, emailFinder, type) 390 await checkNotification(base, notificationChecker, emailFinder, type)
388} 391}
389 392
393async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
394 const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS
395
396 function notificationChecker (notification: UserNotification, type: CheckerType) {
397 if (type === 'presence') {
398 expect(notification).to.not.be.undefined
399 expect(notification.type).to.equal(notificationType)
400
401 expect(notification.video.id).to.be.a('number')
402 checkVideo(notification.video, videoName, videoUUID)
403 } else {
404 expect(notification).to.satisfy((n: UserNotification) => {
405 return n === undefined || n.video === undefined || n.video.uuid !== videoUUID
406 })
407 }
408 }
409
410 function emailFinder (email: object) {
411 const text = email[ 'text' ]
412 return text.indexOf(videoUUID) !== -1 && email[ 'text' ].indexOf('video-auto-blacklist/list') !== -1
413 }
414
415 await checkNotification(base, notificationChecker, emailFinder, type)
416}
417
390async function checkNewBlacklistOnMyVideo ( 418async function checkNewBlacklistOnMyVideo (
391 base: CheckerBaseParams, 419 base: CheckerBaseParams,
392 videoUUID: string, 420 videoUUID: string,
@@ -431,6 +459,7 @@ export {
431 checkCommentMention, 459 checkCommentMention,
432 updateMyNotificationSettings, 460 updateMyNotificationSettings,
433 checkNewVideoAbuseForModerators, 461 checkNewVideoAbuseForModerators,
462 checkVideoAutoBlacklistForModerators,
434 getUserNotifications, 463 getUserNotifications,
435 markAsReadNotifications, 464 markAsReadNotifications,
436 getLastNotification 465 getLastNotification