Compare commits

...

6 commits

Author SHA1 Message Date
Dj Isaac
d4da0de2fc
Merge ecac2917a0 into d7ffa33950 2024-10-18 00:25:35 +00:00
Dj Isaac
ecac2917a0
Merge branch 'master' into dj/discord-service-url 2024-10-09 20:36:06 -05:00
Dj Isaac
8b82520d3d
Conditionally add service url 2024-10-09 20:35:26 -05:00
Dj Isaac
af230ba5fb
Use msg rather than parse it out of the heartbeat
Co-authored-by: Frank Elsinga <frank@elsinga.de>
2024-10-09 20:02:11 -05:00
Dj Isaac
c28710cdc6
fix: remove service name/type from discord notifier 2024-10-09 20:02:07 -05:00
Dj Isaac
0d328e7c8e
fix: misspelling of 'address' (#5180) 2024-10-09 20:01:51 -05:00

View file

@ -33,6 +33,27 @@ class Discord extends NotificationProvider {
return okMsg; return okMsg;
} }
const address = this.extractAddress(monitorJSON);
const embedFields = [
{
name: "Service Name",
value: monitorJSON["name"],
},
...((address !== "" && address !== monitorJSON["hostname"]) ? [{
name: "Service URL",
value: address
}] : []),
{
name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["localDateTime"],
},
{
name: "Error",
value: msg,
},
];
// If heartbeatJSON is not null, we go into the normal alerting loop. // If heartbeatJSON is not null, we go into the normal alerting loop.
if (heartbeatJSON["status"] === DOWN) { if (heartbeatJSON["status"] === DOWN) {
let discorddowndata = { let discorddowndata = {
@ -41,24 +62,7 @@ class Discord extends NotificationProvider {
title: "❌ Your service " + monitorJSON["name"] + " went down. ❌", title: "❌ Your service " + monitorJSON["name"] + " went down. ❌",
color: 16711680, color: 16711680,
timestamp: heartbeatJSON["time"], timestamp: heartbeatJSON["time"],
fields: [ fields: embedFields,
{
name: "Service Name",
value: monitorJSON["name"],
},
{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
value: this.extractAddress(monitorJSON),
},
{
name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["localDateTime"],
},
{
name: "Error",
value: heartbeatJSON["msg"] == null ? "N/A" : heartbeatJSON["msg"],
},
],
}], }],
}; };
if (notification.discordChannelType === "createNewForumPost") { if (notification.discordChannelType === "createNewForumPost") {
@ -78,24 +82,7 @@ class Discord extends NotificationProvider {
title: "✅ Your service " + monitorJSON["name"] + " is up! ✅", title: "✅ Your service " + monitorJSON["name"] + " is up! ✅",
color: 65280, color: 65280,
timestamp: heartbeatJSON["time"], timestamp: heartbeatJSON["time"],
fields: [ fields: embedFields,
{
name: "Service Name",
value: monitorJSON["name"],
},
{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
value: this.extractAddress(monitorJSON),
},
{
name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["localDateTime"],
},
{
name: "Ping",
value: heartbeatJSON["ping"] == null ? "N/A" : heartbeatJSON["ping"] + " ms",
},
],
}], }],
}; };