Skip to content

Commit

Permalink
fix: remove service name/type from discord notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
DeJayDev committed Oct 10, 2024
1 parent 2888aa1 commit 7ca5150
Showing 1 changed file with 17 additions and 36 deletions.
53 changes: 17 additions & 36 deletions server/notification-providers/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ class Discord extends NotificationProvider {
return okMsg;
}

const embedFields = [
{
name: "Service Name",
value: monitorJSON["name"],
},
{
name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["localDateTime"],
},
{
name: "Error",
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 = {
Expand All @@ -41,24 +56,7 @@ class Discord extends NotificationProvider {
title: "❌ Your service " + monitorJSON["name"] + " went down. ❌",
color: 16711680,
timestamp: heartbeatJSON["time"],
fields: [
{
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"],
},
],
fields: embedFields,
}],
};
if (notification.discordChannelType === "createNewForumPost") {
Expand All @@ -78,24 +76,7 @@ class Discord extends NotificationProvider {
title: "✅ Your service " + monitorJSON["name"] + " is up! ✅",
color: 65280,
timestamp: heartbeatJSON["time"],
fields: [
{
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",
},
],
fields: embedFields,
}],
};

Expand Down

0 comments on commit 7ca5150

Please sign in to comment.