diff --git a/server/notification.js b/server/notification.js index 961768ac1..35b22054b 100644 --- a/server/notification.js +++ b/server/notification.js @@ -35,6 +35,93 @@ class Notification { 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 if (notification.type === "webhook") { try { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index d08cb5019..64bd28bcd 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -19,6 +19,7 @@ Discord Signal Gotify + Slack @@ -171,18 +172,31 @@ - - Application Token - - + + Application Token + + - - Server URL - - - + + Server URL + + - + + + + + Slack Webhook URL + + Uptime Kuma URL + + + + + More info on: https://api.slack.com/messaging/webhooks + + +
+ More info on: https://api.slack.com/messaging/webhooks +