From 5d438ca2b615de0612e92777c167445da469ea31 Mon Sep 17 00:00:00 2001 From: Thies Nieborg Date: Wed, 25 Aug 2021 13:07:52 +0200 Subject: [PATCH 1/2] Discord notification URL now also represents non http services --- server/notification.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/notification.js b/server/notification.js index cb77a6190..d81920e25 100644 --- a/server/notification.js +++ b/server/notification.js @@ -95,12 +95,15 @@ class Notification { await axios.post(notification.discordWebhookUrl, discordtestdata) return okMsg; } + let url = monitorJSON["url"] === "https://" ? monitorJSON["hostname"] : monitorJSON["url"] + if (monitorJSON["port"]) url += ":" + monitorJSON[port] + // If heartbeatJSON is not null, we go into the normal alerting loop. if (heartbeatJSON["status"] == 0) { let discorddowndata = { username: discordDisplayName, embeds: [{ - title: "❌ One of your services went down. ❌", + title: "❌ Your service " + monitorJSON["name"] + " went down. ❌", color: 16711680, timestamp: heartbeatJSON["time"], fields: [ @@ -110,7 +113,7 @@ class Notification { }, { name: "Service URL", - value: monitorJSON["url"], + value: url, }, { name: "Time (UTC)", @@ -140,7 +143,7 @@ class Notification { }, { name: "Service URL", - value: "[Visit Service](" + monitorJSON["url"] + ")", + value: url.startsWith("http") ? "[Visit Service](" + url + ")" : url, }, { name: "Time (UTC)", From 72740ba477db016cae89dffceaab6f9f397e8c74 Mon Sep 17 00:00:00 2001 From: Thies <37243142+Thiesjoo@users.noreply.github.com> Date: Wed, 25 Aug 2021 14:08:41 +0200 Subject: [PATCH 2/2] Update the styling to better match existing styles Co-authored-by: Adam Stachowicz --- server/notification.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/notification.js b/server/notification.js index d81920e25..8fb10a38d 100644 --- a/server/notification.js +++ b/server/notification.js @@ -95,8 +95,11 @@ class Notification { await axios.post(notification.discordWebhookUrl, discordtestdata) return okMsg; } + let url = monitorJSON["url"] === "https://" ? monitorJSON["hostname"] : monitorJSON["url"] - if (monitorJSON["port"]) url += ":" + monitorJSON[port] + if (monitorJSON["port"]) { + url += ":" + monitorJSON[port]; + } // If heartbeatJSON is not null, we go into the normal alerting loop. if (heartbeatJSON["status"] == 0) {