diff --git a/server/notification.js b/server/notification.js index 924aa07c..344a427e 100644 --- a/server/notification.js +++ b/server/notification.js @@ -389,6 +389,53 @@ class Notification { } catch (error) { throwGeneralAxiosError(error) } + } else if (notification.type === "line") { + try { + let lineAPIUrl = "https://api.line.me/v2/bot/message/push"; + let config = { + headers: { + "Content-Type": "application/json", + "Authorization": "Bearer " + notification.lineChannelAccessToken + } + }; + if (heartbeatJSON == null) { + let testMessage = { + "to": notification.lineUserID, + "messages": [ + { + "type": "text", + "text":"Test Successful!" + } + ] + } + await axios.post(lineAPIUrl, testMessage, config) + } else if (heartbeatJSON["status"] == 0) { + let downMessage = { + "to": notification.lineUserID, + "messages": [ + { + "type": "text", + "text":"UptimeKuma Alert: [🔴 Down]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"] + } + ] + } + await axios.post(lineAPIUrl, downMessage, config) + } else if (heartbeatJSON["status"] == 1) { + let upMessage = { + "to": notification.lineUserID, + "messages": [ + { + "type": "text", + "text":"UptimeKuma Alert: [✅ Up]\n" + "Name: " + monitorJSON["name"] + " \n" + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"] + } + ] + } + await axios.post(lineAPIUrl, upMessage, 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 5d2dbd6b..76421665 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -26,6 +26,7 @@ + @@ -383,6 +384,26 @@ More info on: https://docs.pushbullet.com
+ + +