From 4e63d000072000fd42f91a528384bbcd82e6b6fb Mon Sep 17 00:00:00 2001 From: nino Date: Wed, 29 May 2024 18:20:33 +0800 Subject: [PATCH 1/2] feat: update feishu notification template --- server/notification-providers/feishu.js | 93 +++++++++++++++---------- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/server/notification-providers/feishu.js b/server/notification-providers/feishu.js index 23af6911..45c4c983 100644 --- a/server/notification-providers/feishu.js +++ b/server/notification-providers/feishu.js @@ -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: true, + 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: true, + 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; From 30bf7a5e23ce95ae6189ce1d0866d89e71924fbd Mon Sep 17 00:00:00 2001 From: nino Date: Wed, 29 May 2024 22:22:05 +0800 Subject: [PATCH 2/2] fix: update Feishu notification provider configuration --- server/notification-providers/feishu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/notification-providers/feishu.js b/server/notification-providers/feishu.js index 45c4c983..cd5331d2 100644 --- a/server/notification-providers/feishu.js +++ b/server/notification-providers/feishu.js @@ -28,7 +28,7 @@ class Feishu extends NotificationProvider { msg_type: "interactive", card: { config: { - update_multi: true, + update_multi: false, wide_screen_mode: true, }, header: { @@ -58,7 +58,7 @@ class Feishu extends NotificationProvider { msg_type: "interactive", card: { config: { - update_multi: true, + update_multi: false, wide_screen_mode: true, }, header: {