From 883993c81ecc2388d4a4b37b29b81b6de73d264f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Apr 2019 17:26:01 +0200 Subject: Add notification on new instance follower (server side) --- shared/utils/users/user-notifications.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'shared/utils/users') 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 ( await checkNotification(base, notificationChecker, emailFinder, type) } +async function checkNewInstanceFollower (base: CheckerBaseParams, followerHost: string, type: CheckerType) { + const notificationType = UserNotificationType.NEW_INSTANCE_FOLLOWER + + function notificationChecker (notification: UserNotification, type: CheckerType) { + if (type === 'presence') { + expect(notification).to.not.be.undefined + expect(notification.type).to.equal(notificationType) + + checkActor(notification.actorFollow.follower) + expect(notification.actorFollow.follower.name).to.equal('peertube') + expect(notification.actorFollow.follower.host).to.equal(followerHost) + + expect(notification.actorFollow.following.name).to.equal('peertube') + } else { + expect(notification).to.satisfy(n => { + return n.type !== notificationType || n.actorFollow.follower.host !== followerHost + }) + } + } + + function emailFinder (email: object) { + const text: string = email[ 'text' ] + + return text.includes('instance has a new follower') && text.includes(followerHost) + } + + await checkNotification(base, notificationChecker, emailFinder, type) +} + async function checkCommentMention ( base: CheckerBaseParams, uuid: string, @@ -462,5 +491,6 @@ export { checkVideoAutoBlacklistForModerators, getUserNotifications, markAsReadNotifications, - getLastNotification + getLastNotification, + checkNewInstanceFollower } -- cgit v1.2.3