]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/utils/users/user-notifications.ts
Add delete/manual approval instance followers in client
[github/Chocobozzz/PeerTube.git] / shared / utils / users / user-notifications.ts
index b85d5d2f19f6dc629960babef51171c0f91407ea..e3a79f523e95c71361a260e9d4f57c0ac651ab74 100644 (file)
@@ -18,7 +18,7 @@ function updateMyNotificationSettings (url: string, token: string, settings: Use
   })
 }
 
-function getUserNotifications (
+async function getUserNotifications (
   url: string,
   token: string,
   start: number,
@@ -165,12 +165,15 @@ async function checkNewVideoFromSubscription (base: CheckerBaseParams, videoName
       checkVideo(notification.video, videoName, videoUUID)
       checkActor(notification.video.channel)
     } else {
-      expect(notification.video).to.satisfy(v => v === undefined || v.name !== videoName)
+      expect(notification).to.satisfy((n: UserNotification) => {
+        return n === undefined || n.type !== UserNotificationType.NEW_VIDEO_FROM_SUBSCRIPTION || n.video.name !== videoName
+      })
     }
   }
 
   function emailFinder (email: object) {
-    return email[ 'text' ].indexOf(videoUUID) !== -1
+    const text = email[ 'text' ]
+    return text.indexOf(videoUUID) !== -1 && text.indexOf('Your subscription') !== -1
   }
 
   await checkNotification(base, notificationChecker, emailFinder, type)
@@ -274,8 +277,8 @@ async function checkNewActorFollow (
       checkActor(notification.actorFollow.follower)
       expect(notification.actorFollow.follower.displayName).to.equal(followerDisplayName)
       expect(notification.actorFollow.follower.name).to.equal(followerName)
+      expect(notification.actorFollow.follower.host).to.not.be.undefined
 
-      checkActor(notification.actorFollow.following)
       expect(notification.actorFollow.following.displayName).to.equal(followingDisplayName)
       expect(notification.actorFollow.following.type).to.equal(followType)
     } else {
@@ -387,6 +390,31 @@ async function checkNewVideoAbuseForModerators (base: CheckerBaseParams, videoUU
   await checkNotification(base, notificationChecker, emailFinder, type)
 }
 
+async function checkVideoAutoBlacklistForModerators (base: CheckerBaseParams, videoUUID: string, videoName: string, type: CheckerType) {
+  const notificationType = UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS
+
+  function notificationChecker (notification: UserNotification, type: CheckerType) {
+    if (type === 'presence') {
+      expect(notification).to.not.be.undefined
+      expect(notification.type).to.equal(notificationType)
+
+      expect(notification.video.id).to.be.a('number')
+      checkVideo(notification.video, videoName, videoUUID)
+    } else {
+      expect(notification).to.satisfy((n: UserNotification) => {
+        return n === undefined || n.video === undefined || n.video.uuid !== videoUUID
+      })
+    }
+  }
+
+  function emailFinder (email: object) {
+    const text = email[ 'text' ]
+    return text.indexOf(videoUUID) !== -1 && email[ 'text' ].indexOf('video-auto-blacklist/list') !== -1
+  }
+
+  await checkNotification(base, notificationChecker, emailFinder, type)
+}
+
 async function checkNewBlacklistOnMyVideo (
   base: CheckerBaseParams,
   videoUUID: string,
@@ -431,6 +459,7 @@ export {
   checkCommentMention,
   updateMyNotificationSettings,
   checkNewVideoAbuseForModerators,
+  checkVideoAutoBlacklistForModerators,
   getUserNotifications,
   markAsReadNotifications,
   getLastNotification