|
|
@ -1,7 +1,7 @@
|
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const axios = require("axios");
|
|
|
|
const axios = require("axios");
|
|
|
|
const { setSettings, setting } = require("../util-server");
|
|
|
|
const { setSettings, setting } = require("../util-server");
|
|
|
|
const { getMonitorRelativeURL } = require("../../src/util");
|
|
|
|
const { getMonitorRelativeURL, UP } = require("../../src/util");
|
|
|
|
|
|
|
|
|
|
|
|
class Slack extends NotificationProvider {
|
|
|
|
class Slack extends NotificationProvider {
|
|
|
|
|
|
|
|
|
|
|
@ -46,24 +46,31 @@ class Slack extends NotificationProvider {
|
|
|
|
"channel": notification.slackchannel,
|
|
|
|
"channel": notification.slackchannel,
|
|
|
|
"username": notification.slackusername,
|
|
|
|
"username": notification.slackusername,
|
|
|
|
"icon_emoji": notification.slackiconemo,
|
|
|
|
"icon_emoji": notification.slackiconemo,
|
|
|
|
"blocks": [{
|
|
|
|
"attachments": [
|
|
|
|
"type": "header",
|
|
|
|
|
|
|
|
"text": {
|
|
|
|
|
|
|
|
"type": "plain_text",
|
|
|
|
|
|
|
|
"text": "Uptime Kuma Alert",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"type": "section",
|
|
|
|
|
|
|
|
"fields": [{
|
|
|
|
|
|
|
|
"type": "mrkdwn",
|
|
|
|
|
|
|
|
"text": "*Message*\n" + msg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"type": "mrkdwn",
|
|
|
|
"color": (heartbeatJSON["status"] === UP) ? "#2eb886" : "#e01e5a",
|
|
|
|
"text": "*Time (UTC)*\n" + time,
|
|
|
|
"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,
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (notification.slackbutton) {
|
|
|
|
if (notification.slackbutton) {
|
|
|
@ -74,17 +81,19 @@ class Slack extends NotificationProvider {
|
|
|
|
|
|
|
|
|
|
|
|
// Button
|
|
|
|
// Button
|
|
|
|
if (baseURL) {
|
|
|
|
if (baseURL) {
|
|
|
|
data.blocks.push({
|
|
|
|
data.attachments.forEach(element => {
|
|
|
|
"type": "actions",
|
|
|
|
element.blocks.push({
|
|
|
|
"elements": [{
|
|
|
|
"type": "actions",
|
|
|
|
"type": "button",
|
|
|
|
"elements": [{
|
|
|
|
"text": {
|
|
|
|
"type": "button",
|
|
|
|
"type": "plain_text",
|
|
|
|
"text": {
|
|
|
|
"text": "Visit Uptime Kuma",
|
|
|
|
"type": "plain_text",
|
|
|
|
},
|
|
|
|
"text": "Visit Uptime Kuma",
|
|
|
|
"value": "Uptime-Kuma",
|
|
|
|
},
|
|
|
|
"url": baseURL + getMonitorRelativeURL(monitorJSON.id),
|
|
|
|
"value": "Uptime-Kuma",
|
|
|
|
}],
|
|
|
|
"url": baseURL + getMonitorRelativeURL(monitorJSON.id),
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|