🌐 Made changes based on reviewers suggestions

- Added translations
- Removed unnecessary placeholder
- Changed placeholder for thread id
- Added helptext for how to obtain thread / post id
- Clarified what happens at "Create new forum post"
- Renamed "Normal" to "Send to channel"
- Removed unnecessary double declaration of threadQuery
- Instead of appending string, append via URL object
pull/4099/head
TheDanniCraft 12 months ago
parent fd45ef2d7a
commit 5a1aefff36

@ -14,10 +14,9 @@ class Discord extends NotificationProvider {
try {
const discordDisplayName = notification.discordUsername || "Uptime Kuma";
let threadQuery = "";
const webhookUrl = new URL(notification.discordWebhookUrl);
if (notification.discordChannelType === "postToThread") {
threadQuery = "?thread_id=" + notification.threadId;
webhookUrl.searchParams.append("thread_id", notification.threadId);
}
// If heartbeatJSON is null, assume we're testing.
@ -31,7 +30,7 @@ class Discord extends NotificationProvider {
discordtestdata.thread_name = notification.postName;
}
await axios.post(notification.discordWebhookUrl + threadQuery, discordtestdata);
await axios.post(webhookUrl.toString(), discordtestdata);
return okMsg;
}
@ -58,11 +57,6 @@ class Discord extends NotificationProvider {
// If heartbeatJSON is not null, we go into the normal alerting loop.
if (heartbeatJSON["status"] === DOWN) {
const discordDisplayName = notification.discordUsername || "Uptime Kuma";
let threadQuery = "";
if (notification.discordChannelType === "postToThread") {
threadQuery = "?thread_id=" + notification.threadId;
}
let discorddowndata = {
username: discordDisplayName,
@ -97,7 +91,7 @@ class Discord extends NotificationProvider {
discorddowndata.content = notification.discordPrefixMessage;
}
await axios.post(notification.discordWebhookUrl + threadQuery, discorddowndata);
await axios.post(webhookUrl.toString(), discorddowndata);
return okMsg;
} else if (heartbeatJSON["status"] === UP) {
@ -136,7 +130,7 @@ class Discord extends NotificationProvider {
discordupdata.content = notification.discordPrefixMessage;
}
await axios.post(notification.discordWebhookUrl + threadQuery, discordupdata);
await axios.post(webhookUrl.toString(), discordupdata);
return okMsg;
}
} catch (error) {

@ -21,22 +21,32 @@
<label for="discord-message-type" class="form-label">{{ $t("Select message type") }}</label>
<br>
<select id="discord-message-type" v-model="$parent.notification.discordChannelType" class="form-select">
<option value="normal">{{ $t("Normal Message") }}</option>
<option value="channel">{{ $t("Send to channel") }}</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 / forum post") }}</option>
</select>
</div>
<div v-if="$parent.notification.discordChannelType === 'createNewForumPost'">
<div class="mb-3">
<label for="discord-target" class="form-label">{{ $t("Forum post name") }}</label>
<input id="discord-target" v-model="$parent.notification.postName" type="text" class="form-control" autocomplete="false" :placeholder="$t('Status Changed')">
<input id="discord-target" v-model="$parent.notification.postName" type="text" class="form-control" autocomplete="false">
<div class="form-text">
{{ $t("whatHappensAtForumPost") }}"{{ $t("Post to existing thread / forum post") }}"
</div>
</div>
</div>
<div v-if="$parent.notification.discordChannelType === 'postToThread'">
<div class="mb-3">
<label for="discord-target" class="form-label">{{ $t("Thread ID") }}</label>
<input id="discord-target" v-model="$parent.notification.threadId" type="text" class="form-control" autocomplete="false" :placeholder="$t('Thread ID (e.g. 1177566663751782411)')">
<label for="discord-target" class="form-label">{{ $t("Thread / Forum post ID") }}</label>
<input id="discord-target" v-model="$parent.notification.threadId" type="text" class="form-control" autocomplete="false" :placeholder="$t('e.g. {discordThreadID}', { discordThreadID: 1177566663751782411 })">
<div class="form-text">
{{ $t("wayToGetDiscordThreadId") }}
<a
href="https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-"
target="_blank"
>{{ $t("here") }}</a>
</div>
</div>
</div>
</template>
@ -44,7 +54,7 @@
export default {
mounted() {
if (!this.$parent.notification.discordChannelType) {
this.$parent.notification.discordChannelType = "normal";
this.$parent.notification.discordChannelType = "channel";
}
}
};

@ -517,6 +517,15 @@
"Bot Display Name": "Bot Display Name",
"Prefix Custom Message": "Prefix Custom Message",
"Hello @everyone is...": "Hello {'@'}everyone is…",
"Select message type": "Select message type",
"Send to channel": "Send to channel",
"Create new forum post": "Create new forum post",
"Post to existing thread / forum post": "Post to existing thread / forum post",
"Forum post name": "Forum post name",
"Thread / Forum post ID": "Thread / Forum post ID",
"e.g. {discordThreadID}": "e.g. {discordThreadID}",
"whatHappensAtForumPost": "Create a new forum post. This does NOT post messages in existing post. To post in existing post use ",
"wayToGetDiscordThreadId": "Getting a thread / forum post id is simmilar to getting a channel id. Read more about how to get ids ",
"wayToGetTeamsURL": "You can learn how to create a webhook URL {0}.",
"wayToGetZohoCliqURL": "You can learn how to create a webhook URL {0}.",
"needSignalAPI": "You need to have a signal client with REST API.",

Loading…
Cancel
Save