🚨Fixed linter warns

pull/4099/head
TheDanniCraft 12 months ago
parent f117342deb
commit 4dc74c42ea

@ -14,9 +14,11 @@ class Discord extends NotificationProvider {
try { try {
const discordDisplayName = notification.discordUsername || "Uptime Kuma"; const discordDisplayName = notification.discordUsername || "Uptime Kuma";
var threadQuery = ""; let threadQuery = "";
if (notification.discordChannelType == "postToThread") threadQuery = "?thread_id=" + notification.threadId; if (notification.discordChannelType === "postToThread") {
threadQuery = "?thread_id=" + notification.threadId;
}
// If heartbeatJSON is null, assume we're testing. // If heartbeatJSON is null, assume we're testing.
if (heartbeatJSON == null) { if (heartbeatJSON == null) {
@ -25,7 +27,9 @@ class Discord extends NotificationProvider {
content: msg, content: msg,
}; };
if (notification.discordChannelType == "createNewForumPost") discordtestdata.thread_name = notification.postName; if (notification.discordChannelType === "createNewForumPost") {
discordtestdata.thread_name = notification.postName;
}
await axios.post(notification.discordWebhookUrl + threadQuery, discordtestdata); await axios.post(notification.discordWebhookUrl + threadQuery, discordtestdata);
return okMsg; return okMsg;
@ -54,9 +58,11 @@ class Discord extends NotificationProvider {
// 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) {
const discordDisplayName = notification.discordUsername || "Uptime Kuma"; const discordDisplayName = notification.discordUsername || "Uptime Kuma";
var threadQuery = ""; let threadQuery = "";
if (notification.discordChannelType == "postToThread") threadQuery = "?thread_id=" + notification.threadId; if (notification.discordChannelType === "postToThread") {
threadQuery = "?thread_id=" + notification.threadId;
}
let discorddowndata = { let discorddowndata = {
username: discordDisplayName, username: discordDisplayName,
@ -84,12 +90,14 @@ class Discord extends NotificationProvider {
], ],
}], }],
}; };
if (notification.discordChannelType == "createNewForumPost") discorddowndata.thread_name = notification.postName; if (notification.discordChannelType === "createNewForumPost") {
discorddowndata.thread_name = notification.postName;
}
if (notification.discordPrefixMessage) { if (notification.discordPrefixMessage) {
discorddowndata.content = notification.discordPrefixMessage; discorddowndata.content = notification.discordPrefixMessage;
} }
await axios.post(notification.discordWebhookUrl, discorddowndata); await axios.post(notification.discordWebhookUrl + threadQuery, discorddowndata);
return okMsg; return okMsg;
} else if (heartbeatJSON["status"] === UP) { } else if (heartbeatJSON["status"] === UP) {
@ -120,7 +128,9 @@ class Discord extends NotificationProvider {
}], }],
}; };
if (notification.discordChannelType == "createNewForumPost") discordupdata.thread_name = notification.postName; if (notification.discordChannelType === "createNewForumPost") {
discordupdata.thread_name = notification.postName;
}
if (notification.discordPrefixMessage) { if (notification.discordPrefixMessage) {
discordupdata.content = notification.discordPrefixMessage; discordupdata.content = notification.discordPrefixMessage;

@ -20,7 +20,7 @@
<div class="mb-3"> <div class="mb-3">
<label for="discord-message-type" class="form-label">{{ $t("Select message type") }}</label> <label for="discord-message-type" class="form-label">{{ $t("Select message type") }}</label>
<br> <br>
<select id="discord-message-type" class="form-select" v-model="$parent.notification.discordChannelType"> <select id="discord-message-type" v-model="$parent.notification.discordChannelType" class="form-select">
<option value="normal">{{ $t("Normal Message") }}</option> <option value="normal">{{ $t("Normal Message") }}</option>
<option value="createNewForumPost">{{ $t("Create new forum post") }}</option> <option value="createNewForumPost">{{ $t("Create new forum post") }}</option>
<option value="postToThread">{{ $t("Post to existing thread") }}</option> <option value="postToThread">{{ $t("Post to existing thread") }}</option>
@ -45,5 +45,5 @@ export default {
mounted() { mounted() {
this.$parent.notification.discordChannelType = "normal"; this.$parent.notification.discordChannelType = "normal";
} }
} };
</script> </script>
Loading…
Cancel
Save