From efe75bde751cb7432b0132c94f4f4b954d522737 Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Fri, 13 Aug 2021 21:18:43 +0100 Subject: [PATCH] Add Pushbullet notification service --- server/notification.js | 35 +++++++++++++++++++++++++++ src/components/NotificationDialog.vue | 12 +++++++++ 2 files changed, 47 insertions(+) diff --git a/server/notification.js b/server/notification.js index 56838513e..ea065b2fa 100644 --- a/server/notification.js +++ b/server/notification.js @@ -354,6 +354,41 @@ class Notification { throwGeneralAxiosError(error) } + } else if (notification.type === "pushbullet") { + try { + let pushbulletUrl = `https://api.pushbullet.com/v2/pushes`; + let config = { + headers: { + 'Access-Token': notification.pushbulletAccessToken, + 'Content-Type': 'application/json' + } + }; + if (heartbeatJSON == null) { + let testdata = { + "type": "note", + "title": "Uptime Kuma Alert", + "body": "Testing Successful.", + } + await axios.post(pushbulletUrl, testdata, config) + } else if (heartbeatJSON["status"] == 0) { + let downdata = { + "type": "note", + "title": "UptimeKuma Alert:" + monitorJSON["name"], + "body": "[🔴 Down]" + heartbeatJSON["msg"] + "\nTime (UTC):" + heartbeatJSON["time"], + } + await axios.post(pushbulletUrl, downdata, config) + } else if (heartbeatJSON["status"] == 1) { + let updata = { + "type": "note", + "title": "UptimeKuma Alert:" + monitorJSON["name"], + "body": "[✅ Up]" + heartbeatJSON["msg"] + "\nTime (UTC):" + heartbeatJSON["time"], + } + await axios.post(pushbulletUrl, updata, config) + } + return okMsg; + } catch (error) { + throwGeneralAxiosError(error) + } } else { throw new Error("Notification type is not supported") } diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index a3e72da07..5d2dbd6b8 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -25,6 +25,7 @@ + @@ -371,6 +372,17 @@ + +