From 44d9967cfb35c887cd14aa8870cad0dedbd647ab Mon Sep 17 00:00:00 2001 From: Thomas Ferney Date: Wed, 25 Aug 2021 21:01:29 +0200 Subject: [PATCH] feat: add rocket.chat notification --- server/notification.js | 34 +++++++++++++++++++++++++++ src/components/NotificationDialog.vue | 31 ++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/server/notification.js b/server/notification.js index cb77a6190..4a1399483 100644 --- a/server/notification.js +++ b/server/notification.js @@ -279,6 +279,40 @@ class Notification { throwGeneralAxiosError(error) } + } else if (notification.type === "rocket.chat") { + try { + if (heartbeatJSON == null) { + let data = { + "text": "Uptime Kuma Rocket.chat testing successful.", + "channel": notification.rocketchannel, + "username": notification.rocketusername, + "icon_emoji": notification.rocketiconemo, + } + await axios.post(notification.rocketwebhookURL, data) + return okMsg; + } + + const time = heartbeatJSON["time"]; + let data = { + "text": "Uptime Kuma Alert", + "channel": notification.rocketchannel, + "username": notification.rocketusername, + "icon_emoji": notification.rocketiconemo, + "attachments": [ + { + "title": "Uptime Kuma Alert *Time (UTC)*\n" + time, + "title_link": notification.rocketbutton, + "text": "*Message*\n" + msg, + "color": "#32cd32" + } + ] + } + await axios.post(notification.rocketwebhookURL, data) + return okMsg; + } catch (error) { + throwGeneralAxiosError(error) + } + } else if (notification.type === "mattermost") { try { const mattermostUserName = notification.mattermostusername || "Uptime Kuma"; diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index d639e4f23..6bfdfad66 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -20,6 +20,7 @@ + @@ -239,6 +240,36 @@ + +