mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-28 08:49:34 -05:00
feat: update feishu notification template (#4800)
This commit is contained in:
commit
40d24e7837
@ -25,25 +25,29 @@ class Feishu extends NotificationProvider {
|
||||
|
||||
if (heartbeatJSON["status"] === DOWN) {
|
||||
let downdata = {
|
||||
msg_type: "post",
|
||||
content: {
|
||||
post: {
|
||||
zh_cn: {
|
||||
title: "UptimeKuma Alert: [Down] " + monitorJSON["name"],
|
||||
content: [
|
||||
[
|
||||
{
|
||||
tag: "text",
|
||||
text:
|
||||
"[Down] " +
|
||||
heartbeatJSON["msg"] +
|
||||
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
msg_type: "interactive",
|
||||
card: {
|
||||
config: {
|
||||
update_multi: false,
|
||||
wide_screen_mode: true,
|
||||
},
|
||||
},
|
||||
header: {
|
||||
title: {
|
||||
tag: "plain_text",
|
||||
content: "UptimeKuma Alert: [Down] " + monitorJSON["name"],
|
||||
},
|
||||
template: "red",
|
||||
},
|
||||
elements: [
|
||||
{
|
||||
tag: "div",
|
||||
text: {
|
||||
tag: "lark_md",
|
||||
content: getContent(heartbeatJSON),
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
await axios.post(notification.feishuWebHookUrl, downdata);
|
||||
return okMsg;
|
||||
@ -51,25 +55,29 @@ class Feishu extends NotificationProvider {
|
||||
|
||||
if (heartbeatJSON["status"] === UP) {
|
||||
let updata = {
|
||||
msg_type: "post",
|
||||
content: {
|
||||
post: {
|
||||
zh_cn: {
|
||||
title: "UptimeKuma Alert: [Up] " + monitorJSON["name"],
|
||||
content: [
|
||||
[
|
||||
{
|
||||
tag: "text",
|
||||
text:
|
||||
"[Up] " +
|
||||
heartbeatJSON["msg"] +
|
||||
`\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
msg_type: "interactive",
|
||||
card: {
|
||||
config: {
|
||||
update_multi: false,
|
||||
wide_screen_mode: true,
|
||||
},
|
||||
},
|
||||
header: {
|
||||
title: {
|
||||
tag: "plain_text",
|
||||
content: "UptimeKuma Alert: [UP] " + monitorJSON["name"],
|
||||
},
|
||||
template: "green",
|
||||
},
|
||||
elements: [
|
||||
{
|
||||
tag: "div",
|
||||
text: {
|
||||
tag: "lark_md",
|
||||
content: getContent(heartbeatJSON),
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
};
|
||||
await axios.post(notification.feishuWebHookUrl, updata);
|
||||
return okMsg;
|
||||
@ -80,4 +88,17 @@ class Feishu extends NotificationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content
|
||||
* @param {?object} heartbeatJSON Heartbeat details (For Up/Down only)
|
||||
* @returns {string} Return Successful Message
|
||||
*/
|
||||
function getContent(heartbeatJSON) {
|
||||
return [
|
||||
"**Message**: " + heartbeatJSON["msg"],
|
||||
"**Ping**: " + (heartbeatJSON["ping"] == null ? "N/A" : heartbeatJSON["ping"] + " ms"),
|
||||
`**Time (${heartbeatJSON["timezone"]})**: ${heartbeatJSON["localDateTime"]}`
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
module.exports = Feishu;
|
||||
|
Loading…
Reference in New Issue
Block a user