aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/models/users/user-notification-setting.model.ts1
-rw-r--r--shared/models/users/user-notification.model.ts7
-rw-r--r--shared/utils/users/user-notifications.ts32
3 files changed, 38 insertions, 2 deletions
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts
index 57b33e4b8..e2a882b69 100644
--- a/shared/models/users/user-notification-setting.model.ts
+++ b/shared/models/users/user-notification-setting.model.ts
@@ -15,4 +15,5 @@ export interface UserNotificationSetting {
15 newUserRegistration: UserNotificationSettingValue 15 newUserRegistration: UserNotificationSettingValue
16 newFollow: UserNotificationSettingValue 16 newFollow: UserNotificationSettingValue
17 commentMention: UserNotificationSettingValue 17 commentMention: UserNotificationSettingValue
18 newInstanceFollower: UserNotificationSettingValue
18} 19}
diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts
index 19892b61a..fafc2b7d7 100644
--- a/shared/models/users/user-notification.model.ts
+++ b/shared/models/users/user-notification.model.ts
@@ -1,3 +1,5 @@
1import { FollowState } from '../actors'
2
1export enum UserNotificationType { 3export enum UserNotificationType {
2 NEW_VIDEO_FROM_SUBSCRIPTION = 1, 4 NEW_VIDEO_FROM_SUBSCRIPTION = 1,
3 NEW_COMMENT_ON_MY_VIDEO = 2, 5 NEW_COMMENT_ON_MY_VIDEO = 2,
@@ -15,7 +17,9 @@ export enum UserNotificationType {
15 NEW_FOLLOW = 10, 17 NEW_FOLLOW = 10,
16 COMMENT_MENTION = 11, 18 COMMENT_MENTION = 11,
17 19
18 VIDEO_AUTO_BLACKLIST_FOR_MODERATORS = 12 20 VIDEO_AUTO_BLACKLIST_FOR_MODERATORS = 12,
21
22 NEW_INSTANCE_FOLLOWER = 13
19} 23}
20 24
21export interface VideoInfo { 25export interface VideoInfo {
@@ -73,6 +77,7 @@ export interface UserNotification {
73 actorFollow?: { 77 actorFollow?: {
74 id: number 78 id: number
75 follower: ActorInfo 79 follower: ActorInfo
80 state: FollowState
76 following: { 81 following: {
77 type: 'account' | 'channel' 82 type: 'account' | 'channel'
78 name: string 83 name: string
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}