diff --git a/.stylelintrc b/.stylelintrc index d981fe782..aad673dbc 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -4,7 +4,6 @@ "indentation": 4, "no-descending-specificity": null, "selector-list-comma-newline-after": null, - "declaration-empty-line-before": null, - "no-duplicate-selectors": null + "declaration-empty-line-before": null } } diff --git a/server/notification.js b/server/notification.js index 446753ea4..cb77a6190 100644 --- a/server/notification.js +++ b/server/notification.js @@ -279,6 +279,116 @@ class Notification { throwGeneralAxiosError(error) } + } else if (notification.type === "mattermost") { + try { + const mattermostUserName = notification.mattermostusername || "Uptime Kuma"; + // If heartbeatJSON is null, assume we're testing. + if (heartbeatJSON == null) { + let mattermostTestData = { + username: mattermostUserName, + text: msg, + } + await axios.post(notification.mattermostWebhookUrl, mattermostTestData) + return okMsg; + } + + const mattermostChannel = notification.mattermostchannel; + const mattermostIconEmoji = notification.mattermosticonemo; + const mattermostIconUrl = notification.mattermosticonurl; + + if (heartbeatJSON["status"] == 0) { + let mattermostdowndata = { + username: mattermostUserName, + text: "Uptime Kuma Alert", + channel: mattermostChannel, + icon_emoji: mattermostIconEmoji, + icon_url: mattermostIconUrl, + attachments: [ + { + fallback: + "Your " + + monitorJSON["name"] + + " service went down.", + color: "#FF0000", + title: + "❌ " + + monitorJSON["name"] + + " service went down. ❌", + title_link: monitorJSON["url"], + fields: [ + { + short: true, + title: "Service Name", + value: monitorJSON["name"], + }, + { + short: true, + title: "Time (UTC)", + value: heartbeatJSON["time"], + }, + { + short: false, + title: "Error", + value: heartbeatJSON["msg"], + }, + ], + }, + ], + }; + await axios.post( + notification.mattermostWebhookUrl, + mattermostdowndata + ); + return okMsg; + } else if (heartbeatJSON["status"] == 1) { + let mattermostupdata = { + username: mattermostUserName, + text: "Uptime Kuma Alert", + channel: mattermostChannel, + icon_emoji: mattermostIconEmoji, + icon_url: mattermostIconUrl, + attachments: [ + { + fallback: + "Your " + + monitorJSON["name"] + + " service went up!", + color: "#32CD32", + title: + "✅ " + + monitorJSON["name"] + + " service went up! ✅", + title_link: monitorJSON["url"], + fields: [ + { + short: true, + title: "Service Name", + value: monitorJSON["name"], + }, + { + short: true, + title: "Time (UTC)", + value: heartbeatJSON["time"], + }, + { + short: false, + title: "Ping", + value: heartbeatJSON["ping"] + "ms", + }, + ], + }, + ], + }; + await axios.post( + notification.mattermostWebhookUrl, + mattermostupdata + ); + return okMsg; + } + } catch (error) { + throwGeneralAxiosError(error); + } + } else if (notification.type === "pushover") { let pushoverlink = "https://api.pushover.net/1/messages.json" try { diff --git a/src/components/HeartbeatBar.vue b/src/components/HeartbeatBar.vue index 1f403dd27..33b003db3 100644 --- a/src/components/HeartbeatBar.vue +++ b/src/components/HeartbeatBar.vue @@ -163,10 +163,6 @@ export default { &.empty { background-color: aliceblue; - - .dark & { - background-color: #d0d3d5; - } } &.down { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index b5fe32edd..d2c282099 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -27,6 +27,7 @@ + @@ -238,6 +239,39 @@ + +