Skip to content

Commit

Permalink
bug(Reminder): fix push messages not sending error
Browse files Browse the repository at this point in the history
- push messages are not sent due to a JSON parsing error in the sendReminder.js file
- the solution implemented is to parse push subscription JSON from the database before feeding into webpush

[Delivers #160025746]
  • Loading branch information
olusoladavid committed Aug 24, 2018
1 parent f78b0ec commit bcfb71c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions server/workers/sendReminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ const processNotifications = async () => {
if (users) {
users.forEach(async (user) => {
if (user.reminderisset) {
const msg = '{ type: reminder }';
const options = { TTL: 86400 };
await webpush.sendNotification(user.push_sub, msg, options).catch(() => {
try {
const msg = '{ type: reminder }';
const options = { TTL: 86400 };
const pushSub = JSON.parse(user.push_sub);
await webpush.sendNotification(pushSub, msg, options);
} catch (err) {
console.error(`Could not send reminder for user: ${user.email}`);
});
}
}
});
}
Expand Down

0 comments on commit bcfb71c

Please sign in to comment.