aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/users
diff options
context:
space:
mode:
Diffstat (limited to 'shared/utils/users')
-rw-r--r--shared/utils/users/user-notifications.ts32
1 files changed, 31 insertions, 1 deletions
diff --git a/shared/utils/users/user-notifications.ts b/shared/utils/users/user-notifications.ts
index e3a79f523..495ff80d9 100644
--- a/shared/utils/users/user-notifications.ts
+++ b/shared/utils/users/user-notifications.ts
@@ -298,6 +298,35 @@ async function checkNewActorFollow (
298 await checkNotification(base, notificationChecker, emailFinder, type) 298 await checkNotification(base, notificationChecker, emailFinder, type)
299} 299}
300 300
301async function checkNewInstanceFollower (base: CheckerBaseParams, followerHost: string, type: CheckerType) {
302 const notificationType = UserNotificationType.NEW_INSTANCE_FOLLOWER
303
304 function notificationChecker (notification: UserNotification, type: CheckerType) {
305 if (type === 'presence') {
306 expect(notification).to.not.be.undefined
307 expect(notification.type).to.equal(notificationType)
308
309 checkActor(notification.actorFollow.follower)
310 expect(notification.actorFollow.follower.name).to.equal('peertube')
311 expect(notification.actorFollow.follower.host).to.equal(followerHost)
312
313 expect(notification.actorFollow.following.name).to.equal('peertube')
314 } else {
315 expect(notification).to.satisfy(n => {
316 return n.type !== notificationType || n.actorFollow.follower.host !== followerHost
317 })
318 }
319 }
320
321 function emailFinder (email: object) {
322 const text: string = email[ 'text' ]
323
324 return text.includes('instance has a new follower') && text.includes(followerHost)
325 }
326
327 await checkNotification(base, notificationChecker, emailFinder, type)
328}
329
301async function checkCommentMention ( 330async function checkCommentMention (
302 base: CheckerBaseParams, 331 base: CheckerBaseParams,
303 uuid: string, 332 uuid: string,
@@ -462,5 +491,6 @@ export {
462 checkVideoAutoBlacklistForModerators, 491 checkVideoAutoBlacklistForModerators,
463 getUserNotifications, 492 getUserNotifications,
464 markAsReadNotifications, 493 markAsReadNotifications,
465 getLastNotification 494 getLastNotification,
495 checkNewInstanceFollower
466} 496}