@@ -10,6 +10,7 @@ import { Profile } from "src/core/profiles";
10
10
import { getRequiredStringConfig } from "src/utils/config.helper" ;
11
11
12
12
import { NotificationGateway } from "../../client/gateways/notification.gateway" ;
13
+ import { NotificationWebPushGateway } from "../../client/gateways/notification.web-push.gateway" ;
13
14
import { Notification } from "../../infrastructure/entities/notification.entity" ;
14
15
import { INotification } from "../../types" ;
15
16
@@ -24,6 +25,7 @@ export class NotificationService {
24
25
@InjectRepository ( Notification )
25
26
private readonly notifications : Repository < Notification > ,
26
27
private readonly notificationGateway : NotificationGateway ,
28
+ private readonly notificationWebPushGateway : NotificationWebPushGateway ,
27
29
@InjectRepository ( OrganizationMembership )
28
30
private readonly organizationMemberships : Repository < OrganizationMembership > ,
29
31
@InjectRepository ( Profile )
@@ -61,6 +63,10 @@ export class NotificationService {
61
63
} ) ;
62
64
await this . notifications . save ( newNotifications ) ;
63
65
66
+ // TODO: Do not send web push if web socket succeded
67
+ const profileIds = memberships . map ( ( membership ) => membership . profile . id ) ;
68
+ await this . notificationWebPushGateway . sendWebPush ( profileIds , notification ) ;
69
+
64
70
const userIds = memberships . map ( ( membership ) => membership . profile . userId ) ;
65
71
await this . notifyUsers ( userIds , notification ) ;
66
72
}
@@ -72,6 +78,9 @@ export class NotificationService {
72
78
where : { id : In ( profileIds ) } ,
73
79
} ) ;
74
80
81
+ // TODO: Do not send web push if web socket succeded
82
+ await this . notificationWebPushGateway . sendWebPush ( profileIds , notification ) ;
83
+
75
84
const ids = profiles . map ( ( profile ) => profile . userId ) ;
76
85
77
86
await this . notifyUsers ( ids , notification ) ;
0 commit comments