Skip to content

Commit

Permalink
Merge pull request #105 from dvishal485/main
Browse files Browse the repository at this point in the history
update notif send logic
  • Loading branch information
dvishal485 authored Aug 26, 2024
2 parents 39d923b + 99dfe65 commit 4f30d2f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/api/controllers/notificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ export const push_notification = async () => {
PRIVATE_KEY,
);

for (const subscription of subscriptions) {
await webpush.sendNotification(subscription, notificationPayload);
}
subscriptions.forEach((subscription) => {
webpush
.sendNotification(subscription, notificationPayload)
.then(() => {
console.log("Notification sent");
})
.catch(async (err) => {
console.error("Error sending notification", err);
await subscription.deleteOne();
});
});
};

export const test_notif = asyncErrorHandler(async (req, res, _next) => {
Expand Down

0 comments on commit 4f30d2f

Please sign in to comment.