fix(discord): hide empty Service URL and N/A Ping fields

- Only show Service URL field when extractAddress returns a non-empty value
- Only show Ping field when ping value is not null
- This fixes unnecessary 'https://' and 'N/A' values showing for groups

Fixes #3327

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=101010297
This commit is contained in:
DanielDerefaka 2026-01-01 11:07:16 +01:00
parent 5e6982c500
commit b16aa9c832

View File

@ -58,7 +58,7 @@ class Discord extends NotificationProvider {
name: "Service Name",
value: monitorJSON["name"],
},
...(!notification.disableUrl ? [{
...((!notification.disableUrl && this.extractAddress(monitorJSON)) ? [{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
value: this.extractAddress(monitorJSON),
}] : []),
@ -98,7 +98,7 @@ class Discord extends NotificationProvider {
name: "Service Name",
value: monitorJSON["name"],
},
...(!notification.disableUrl ? [{
...((!notification.disableUrl && this.extractAddress(monitorJSON)) ? [{
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
value: this.extractAddress(monitorJSON),
}] : []),
@ -106,10 +106,10 @@ class Discord extends NotificationProvider {
name: `Time (${heartbeatJSON["timezone"]})`,
value: heartbeatJSON["localDateTime"],
},
{
...(heartbeatJSON["ping"] != null ? [{
name: "Ping",
value: heartbeatJSON["ping"] == null ? "N/A" : heartbeatJSON["ping"] + " ms",
},
value: heartbeatJSON["ping"] + " ms",
}] : []),
],
}],
};