From bcfb71c92596c9e05f36636065dad5b6cc51c519 Mon Sep 17 00:00:00 2001 From: Olusola David Date: Fri, 24 Aug 2018 18:20:52 +0100 Subject: [PATCH] bug(Reminder): fix push messages not sending error - 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] --- server/workers/sendReminder.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/workers/sendReminder.js b/server/workers/sendReminder.js index a9ab911..d261253 100644 --- a/server/workers/sendReminder.js +++ b/server/workers/sendReminder.js @@ -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}`); - }); + } } }); }