From 67909bc71a0851767a6b0506de49d4eab8f13928 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 18 Aug 2021 18:43:26 +0200 Subject: [PATCH] Log Pushover response status code Update title --- src/notification/facade.js | 2 +- src/notification/repository.js | 1 + src/transport/pushover.js | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/notification/facade.js b/src/notification/facade.js index 4fa5ae2..e77f9e2 100644 --- a/src/notification/facade.js +++ b/src/notification/facade.js @@ -130,7 +130,7 @@ class NotificationFacade try { this.logger.info(`Sending notification '${notification.id}' with token '${notification.token}' to '${contact.description}' (attempt ${attempt})`); - await transport.send(contact, notification); + await transport.send(this.logger, contact, notification); this.logger.info(`Notification '${notification.id}' succesfully sent to '${contact.description}'`); return; diff --git a/src/notification/repository.js b/src/notification/repository.js index eb3f4d7..bd8117c 100644 --- a/src/notification/repository.js +++ b/src/notification/repository.js @@ -69,6 +69,7 @@ class NotificationRepository } this.logger.info(`Latching notification with id ${id} and token '${token}', send permitted`); + notification.title = title; notification.latched = true; notification.latchTime = now; notification.reminders = true; diff --git a/src/transport/pushover.js b/src/transport/pushover.js index bc5a3a5..6ad5736 100644 --- a/src/transport/pushover.js +++ b/src/transport/pushover.js @@ -3,7 +3,7 @@ const axios = require('axios'); class PushoverTransport { - async send(contact, notification) + async send(logger, contact, notification) { try { @@ -21,7 +21,9 @@ class PushoverTransport data.sound = notification.sound; const response = await axios.post("https://api.pushover.net/1/messages.json", data); - return response.statu; + logger.verbose(`Pushover API returned status code ${response.status}`); + + return response.status === 200; } catch {