mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-05 17:04:46 +00:00
Add slack support for SLOW/NOMINAL notification cards
This commit is contained in:
parent
7d5297df9d
commit
19799e5d9d
1 changed files with 20 additions and 2 deletions
|
@ -1,11 +1,12 @@
|
||||||
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, UP } = require("../../src/util");
|
const { getMonitorRelativeURL, UP, DOWN, NOMINAL, SLOW } = require("../../src/util");
|
||||||
|
|
||||||
class Slack extends NotificationProvider {
|
class Slack extends NotificationProvider {
|
||||||
|
|
||||||
name = "slack";
|
name = "slack";
|
||||||
|
supportSlowNotifications = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deprecated property notification.slackbutton
|
* Deprecated property notification.slackbutton
|
||||||
|
@ -50,6 +51,23 @@ class Slack extends NotificationProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
const textMsg = "Uptime Kuma Alert";
|
const textMsg = "Uptime Kuma Alert";
|
||||||
|
|
||||||
|
let color;
|
||||||
|
switch(heartbeatJSON["status"]) {
|
||||||
|
case UP:
|
||||||
|
case NOMINAL:
|
||||||
|
color = "#2eb886";
|
||||||
|
break;
|
||||||
|
case SLOW:
|
||||||
|
color = "#ffc107";
|
||||||
|
break;
|
||||||
|
case DOWN:
|
||||||
|
color = "#e01e5a"
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = "#0dcaf0";
|
||||||
|
}
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
"text": `${textMsg}\n${msg}`,
|
"text": `${textMsg}\n${msg}`,
|
||||||
"channel": notification.slackchannel,
|
"channel": notification.slackchannel,
|
||||||
|
@ -57,7 +75,7 @@ class Slack extends NotificationProvider {
|
||||||
"icon_emoji": notification.slackiconemo,
|
"icon_emoji": notification.slackiconemo,
|
||||||
"attachments": [
|
"attachments": [
|
||||||
{
|
{
|
||||||
"color": (heartbeatJSON["status"] === UP) ? "#2eb886" : "#e01e5a",
|
"color": color,
|
||||||
"blocks": [
|
"blocks": [
|
||||||
{
|
{
|
||||||
"type": "header",
|
"type": "header",
|
||||||
|
|
Loading…
Add table
Reference in a new issue