|
|
@ -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,7 +46,11 @@ 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": [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"color": (heartbeatJSON["status"] === UP) ? "#2eb886" : "#e01e5a",
|
|
|
|
|
|
|
|
"blocks": [
|
|
|
|
|
|
|
|
{
|
|
|
|
"type": "header",
|
|
|
|
"type": "header",
|
|
|
|
"text": {
|
|
|
|
"text": {
|
|
|
|
"type": "plain_text",
|
|
|
|
"type": "plain_text",
|
|
|
@ -63,7 +67,10 @@ class Slack extends NotificationProvider {
|
|
|
|
"type": "mrkdwn",
|
|
|
|
"type": "mrkdwn",
|
|
|
|
"text": "*Time (UTC)*\n" + time,
|
|
|
|
"text": "*Time (UTC)*\n" + time,
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (notification.slackbutton) {
|
|
|
|
if (notification.slackbutton) {
|
|
|
@ -74,7 +81,8 @@ class Slack extends NotificationProvider {
|
|
|
|
|
|
|
|
|
|
|
|
// Button
|
|
|
|
// Button
|
|
|
|
if (baseURL) {
|
|
|
|
if (baseURL) {
|
|
|
|
data.blocks.push({
|
|
|
|
data.attachments.forEach(element => {
|
|
|
|
|
|
|
|
element.blocks.push({
|
|
|
|
"type": "actions",
|
|
|
|
"type": "actions",
|
|
|
|
"elements": [{
|
|
|
|
"elements": [{
|
|
|
|
"type": "button",
|
|
|
|
"type": "button",
|
|
|
@ -86,6 +94,7 @@ class Slack extends NotificationProvider {
|
|
|
|
"url": baseURL + getMonitorRelativeURL(monitorJSON.id),
|
|
|
|
"url": baseURL + getMonitorRelativeURL(monitorJSON.id),
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await axios.post(notification.slackwebhookURL, data);
|
|
|
|
await axios.post(notification.slackwebhookURL, data);
|
|
|
|