From 8725e5daf91399fd59a5d016fcb3ae7ac98b9e25 Mon Sep 17 00:00:00 2001 From: Bobby Ore Date: Wed, 8 Feb 2023 14:08:25 -0600 Subject: [PATCH 1/5] Add ability to use User ID for LunaSea notifications --- server/notification-providers/lunasea.js | 15 ++++++++++----- src/components/notifications/LunaSea.vue | 13 +++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/server/notification-providers/lunasea.js b/server/notification-providers/lunasea.js index 2985425e..48f7b4f2 100644 --- a/server/notification-providers/lunasea.js +++ b/server/notification-providers/lunasea.js @@ -8,15 +8,20 @@ class LunaSea extends NotificationProvider { async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { let okMsg = "Sent Successfully."; - let lunaseadevice = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaDevice; - + let lunaseaurl = ""; + if(notification.lunaseaNotificationType === "device") { + lunaseaurl = "https://notify.lunasea.app/v1/custom/device/" + notification.lunaseaId; + } else { + lunaseaurl = "https://notify.lunasea.app/v1/custom/user/" + notification.lunaseaId; + } + try { if (heartbeatJSON == null) { let testdata = { "title": "Uptime Kuma Alert", "body": msg, }; - await axios.post(lunaseadevice, testdata); + await axios.post(lunaseaurl, testdata); return okMsg; } @@ -25,7 +30,7 @@ class LunaSea extends NotificationProvider { "title": "UptimeKuma Alert: " + monitorJSON["name"], "body": "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"], }; - await axios.post(lunaseadevice, downdata); + await axios.post(lunaseaurl, downdata); return okMsg; } @@ -34,7 +39,7 @@ class LunaSea extends NotificationProvider { "title": "UptimeKuma Alert: " + monitorJSON["name"], "body": "[✅ Up] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"], }; - await axios.post(lunaseadevice, updata); + await axios.post(lunaseaurl, updata); return okMsg; } diff --git a/src/components/notifications/LunaSea.vue b/src/components/notifications/LunaSea.vue index 34a98688..6367af7e 100644 --- a/src/components/notifications/LunaSea.vue +++ b/src/components/notifications/LunaSea.vue @@ -1,7 +1,16 @@