From 5f6d5588a6c84364b38a00a4051b3231f00a684a Mon Sep 17 00:00:00 2001 From: Niyas <54862871+NiNiyas@users.noreply.github.com> Date: Wed, 14 Jul 2021 21:07:14 +0530 Subject: [PATCH 1/3] Added Slack Webhook support --- server/notification.js | 87 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/server/notification.js b/server/notification.js index ffd030cb..37a2aaa0 100644 --- a/server/notification.js +++ b/server/notification.js @@ -124,6 +124,93 @@ class Notification { console.log(error) return false; } + + } else if (notification.type === "slack") { + try { + if (heartbeatJSON == null) { + let data = { + "blocks": [{ + "type": "header", + "text": { + "type": "plain_text", + "text": "Uptime Kuma - Slack Testing" + } + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": "*Message*\nSlack Testing" + }, + { + "type": "mrkdwn", + "text": "*Time (UTC)*\nSlack Testing" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Visit Uptime Kuma", + }, + "value": "Uptime-Kuma", + "url": notification.slackbutton + } + ] + } + ] + } + let res = await axios.post(notification.slackwebhookURL, data) + return true; + } + + const time = heartbeatJSON["time"]; + let data = { + "blocks": [{ + "type": "header", + "text": { + "type": "plain_text", + "text": "Uptime Kuma Alert" + } + }, + { + "type": "section", + "fields": [{ + "type": "mrkdwn", + "text": '*Message*\n'+msg + }, + { + "type": "mrkdwn", + "text": "*Time (UTC)*\n"+time + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Visit Uptime Kuma", + }, + "value": "Uptime-Kuma", + "url": notification.slackbutton + } + ] + } + ] + } + let res = await axios.post(notification.slackwebhookURL, data) + return true; + } catch (error) { + console.log(error) + return false; + } } else { throw new Error("Notification type is not supported") From 63c6e29e62e4372031ae5138f8372a09d0298c2f Mon Sep 17 00:00:00 2001 From: Niyas <54862871+NiNiyas@users.noreply.github.com> Date: Wed, 14 Jul 2021 21:08:38 +0530 Subject: [PATCH 2/3] Added Slack Webhook support --- src/components/NotificationDialog.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index d08cb501..b94dd0d7 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -19,6 +19,7 @@ + @@ -175,7 +176,6 @@ -
@@ -183,6 +183,20 @@
+ +