diff --git a/server/notification.js b/server/notification.js index 8c7e9f5e..99cc1568 100644 --- a/server/notification.js +++ b/server/notification.js @@ -124,6 +124,58 @@ class Notification { console.log(error) return false; } + + } else if (notification.type === "slack") { + try { + if (heartbeatJSON == null) { + let data = {'text': "Uptime Kuma Slack testing successful."} + 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") diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 73354f2c..03228a8c 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -19,6 +19,7 @@ + @@ -175,7 +176,6 @@ -
@@ -188,6 +188,20 @@
+ +