aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/users/user-notifications.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-08 17:26:01 +0200
committerChocobozzz <me@florianbigard.com>2019-04-08 17:30:48 +0200
commit883993c81ecc2388d4a4b37b29b81b6de73d264f (patch)
treef0f76995b6762b10a0c1a7ccc2b5d952f68014ea /shared/utils/users/user-notifications.ts
parent0dc647775881eb1378b213a530996cd096de24ea (diff)
downloadPeerTube-883993c81ecc2388d4a4b37b29b81b6de73d264f.tar.gz
PeerTube-883993c81ecc2388d4a4b37b29b81b6de73d264f.tar.zst
PeerTube-883993c81ecc2388d4a4b37b29b81b6de73d264f.zip
Add notification on new instance follower (server side)
Diffstat (limited to 'shared/utils/users/user-notifications.ts')
-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}