|
|
|
@ -13,6 +13,10 @@ class Discord extends NotificationProvider {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const discordDisplayName = notification.discordUsername || "Uptime Kuma";
|
|
|
|
|
const webhookUrl = new URL(notification.discordWebhookUrl);
|
|
|
|
|
if (notification.discordChannelType === "postToThread") {
|
|
|
|
|
webhookUrl.searchParams.append("thread_id", notification.threadId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If heartbeatJSON is null, assume we're testing.
|
|
|
|
|
if (heartbeatJSON == null) {
|
|
|
|
@ -20,7 +24,12 @@ class Discord extends NotificationProvider {
|
|
|
|
|
username: discordDisplayName,
|
|
|
|
|
content: msg,
|
|
|
|
|
};
|
|
|
|
|
await axios.post(notification.discordWebhookUrl, discordtestdata);
|
|
|
|
|
|
|
|
|
|
if (notification.discordChannelType === "createNewForumPost") {
|
|
|
|
|
discordtestdata.thread_name = notification.postName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await axios.post(webhookUrl.toString(), discordtestdata);
|
|
|
|
|
return okMsg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -72,12 +81,14 @@ class Discord extends NotificationProvider {
|
|
|
|
|
],
|
|
|
|
|
}],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (notification.discordChannelType === "createNewForumPost") {
|
|
|
|
|
discorddowndata.thread_name = notification.postName;
|
|
|
|
|
}
|
|
|
|
|
if (notification.discordPrefixMessage) {
|
|
|
|
|
discorddowndata.content = notification.discordPrefixMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await axios.post(notification.discordWebhookUrl, discorddowndata);
|
|
|
|
|
await axios.post(webhookUrl.toString(), discorddowndata);
|
|
|
|
|
return okMsg;
|
|
|
|
|
|
|
|
|
|
} else if (heartbeatJSON["status"] === UP) {
|
|
|
|
@ -108,11 +119,15 @@ class Discord extends NotificationProvider {
|
|
|
|
|
}],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (notification.discordChannelType === "createNewForumPost") {
|
|
|
|
|
discordupdata.thread_name = notification.postName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (notification.discordPrefixMessage) {
|
|
|
|
|
discordupdata.content = notification.discordPrefixMessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await axios.post(notification.discordWebhookUrl, discordupdata);
|
|
|
|
|
await axios.post(webhookUrl.toString(), discordupdata);
|
|
|
|
|
return okMsg;
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|