From 697fa6bdfdb9e6df118b3ea53804475e11fae5be Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 31 Aug 2021 22:15:02 +0800 Subject: [PATCH] fix discord notification appended port unexpectedly --- server/notification.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/notification.js b/server/notification.js index 8cc79d86..472012af 100644 --- a/server/notification.js +++ b/server/notification.js @@ -96,9 +96,16 @@ class Notification { return okMsg; } - let url = monitorJSON["url"] === "https://" ? monitorJSON["hostname"] : monitorJSON["url"] - if (monitorJSON["port"]) { - url += ":" + monitorJSON[port]; + let url; + + if (monitorJSON["type"] === "port") { + url = monitorJSON["hostname"]; + if (monitorJSON["port"]) { + url += ":" + monitorJSON["port"]; + } + + } else { + url = monitorJSON["url"]; } // If heartbeatJSON is not null, we go into the normal alerting loop. @@ -331,7 +338,7 @@ class Notification { await axios.post(notification.mattermostWebhookUrl, mattermostTestData) return okMsg; } - + const mattermostChannel = notification.mattermostchannel; const mattermostIconEmoji = notification.mattermosticonemo; const mattermostIconUrl = notification.mattermosticonurl;