Skip to content

Commit 657388a

Browse files
Johan BookJohan Book
Johan Book
authored and
Johan Book
committed
feat(api): enable web push notifications
1 parent b0a986c commit 657388a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

services/api/src/core/notifications/client/gateways/notification.web-push.gateway.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ export class NotificationWebPushGateway {
1818
);
1919
}
2020

21-
public async sendWebPush(profileId: number, notification: INotification) {
21+
public async sendWebPush(
22+
profileId: number,
23+
notification: INotification,
24+
): Promise<boolean> {
2225
const pushSubscription =
2326
this.notificationSubscriptionService.getSubscription(profileId);
2427

2528
if (!pushSubscription) {
26-
return;
29+
return false;
2730
}
2831

29-
await sendNotification(pushSubscription, JSON.stringify(notification));
32+
const result = await sendNotification(
33+
pushSubscription,
34+
JSON.stringify(notification),
35+
);
36+
37+
return result.statusCode < 400;
3038
}
3139
}

0 commit comments

Comments
 (0)