[slack] allow the user to choose the message format to send (#5167)

Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
Daan Meijer
2024-10-08 12:09:58 +02:00
committed by GitHub
parent 6476e58907
commit 59e70cb763
3 changed files with 17 additions and 4 deletions

View File

@@ -139,17 +139,22 @@ class Slack extends NotificationProvider {
const title = "Uptime Kuma Alert";
let data = {
"text": `${title}\n${msg}`,
"channel": notification.slackchannel,
"username": notification.slackusername,
"icon_emoji": notification.slackiconemo,
"attachments": [
"attachments": [],
};
if (notification.slackrichmessage) {
data.attachments.push(
{
"color": (heartbeatJSON["status"] === UP) ? "#2eb886" : "#e01e5a",
"blocks": Slack.buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg),
}
]
};
);
} else {
data.text = `${title}\n${msg}`;
}
if (notification.slackbutton) {
await Slack.deprecateURL(notification.slackbutton);