fix: remove service name/type from discord notifier

This commit is contained in:
Dj Isaac 2024-10-09 17:03:48 -05:00
parent 0d328e7c8e
commit c28710cdc6
No known key found for this signature in database

View file

@ -33,23 +33,11 @@ class Discord extends NotificationProvider {
return okMsg; return okMsg;
} }
// If heartbeatJSON is not null, we go into the normal alerting loop. const embedFields = [
if (heartbeatJSON["status"] === DOWN) {
let discorddowndata = {
username: discordDisplayName,
embeds: [{
title: "❌ Your service " + monitorJSON["name"] + " went down. ❌",
color: 16711680,
timestamp: heartbeatJSON["time"],
fields: [
{ {
name: "Service Name", name: "Service Name",
value: monitorJSON["name"], value: monitorJSON["name"],
}, },
{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
value: this.extractAddress(monitorJSON),
},
{ {
name: `Time (${heartbeatJSON["timezone"]})`, name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["localDateTime"], value: heartbeatJSON["localDateTime"],
@ -58,7 +46,17 @@ class Discord extends NotificationProvider {
name: "Error", name: "Error",
value: heartbeatJSON["msg"] == null ? "N/A" : heartbeatJSON["msg"], value: heartbeatJSON["msg"] == null ? "N/A" : heartbeatJSON["msg"],
}, },
], ];
// If heartbeatJSON is not null, we go into the normal alerting loop.
if (heartbeatJSON["status"] === DOWN) {
let discorddowndata = {
username: discordDisplayName,
embeds: [{
title: "❌ Your service " + monitorJSON["name"] + " went down. ❌",
color: 16711680,
timestamp: heartbeatJSON["time"],
fields: embedFields,
}], }],
}; };
if (notification.discordChannelType === "createNewForumPost") { if (notification.discordChannelType === "createNewForumPost") {
@ -78,24 +76,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",
},
],
}], }],
}; };