diff --git a/server/notification-providers/wecom.js b/server/notification-providers/wecom.js index 6054208be..d0fbc4a0c 100644 --- a/server/notification-providers/wecom.js +++ b/server/notification-providers/wecom.js @@ -18,7 +18,7 @@ class WeCom extends NotificationProvider { }, }; config = this.getAxiosConfigWithProxy(config); - let body = this.composeMessage(heartbeatJSON, msg); + let body = this.composeMessage(notification, heartbeatJSON, msg); await axios.post( `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${notification.weComBotKey}`, body, @@ -32,11 +32,12 @@ class WeCom extends NotificationProvider { /** * Generate the message to send + * @param {object} notification Notification configuration * @param {object} heartbeatJSON Heartbeat details (For Up/Down only) * @param {string} msg General message * @returns {object} Message */ - composeMessage(heartbeatJSON, msg) { + composeMessage(notification, heartbeatJSON, msg) { let title = "UptimeKuma Message"; if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === UP) { title = "UptimeKuma Monitor Up"; @@ -44,11 +45,26 @@ class WeCom extends NotificationProvider { if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === DOWN) { title = "UptimeKuma Monitor Down"; } + + let textObj = { + content: title + "\n" + msg, + }; + + // Handle mentioned_mobile_list if configured + if (notification.weComMentionedMobileList?.trim()) { + let mentionedMobiles = notification.weComMentionedMobileList + .split(",") + .map((mobile) => mobile.trim()) + .filter((mobile) => mobile.length > 0); + + if (mentionedMobiles.length > 0) { + textObj.mentioned_mobile_list = mentionedMobiles; + } + } + return { msgtype: "text", - text: { - content: title + "\n" + msg, - }, + text: textObj, }; } } diff --git a/src/components/notifications/WeCom.vue b/src/components/notifications/WeCom.vue index bb40a4a78..3183f010c 100644 --- a/src/components/notifications/WeCom.vue +++ b/src/components/notifications/WeCom.vue @@ -23,4 +23,16 @@ + +
+ + +

{{ $t("WeCom Mentioned Mobile List Description") }}

+
diff --git a/src/lang/en.json b/src/lang/en.json index f8d6c583f..a03db37b8 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -793,6 +793,8 @@ "Retry": "Retry", "Topic": "Topic", "WeCom Bot Key": "WeCom Bot Key", + "WeCom Mentioned Mobile List": "WeCom Mentioned Mobile List", + "WeCom Mentioned Mobile List Description": "Enter phone numbers to mention. Separate multiple numbers with commas. Use {'@'}all to mention everyone.", "Setup Proxy": "Set Up Proxy", "Proxy Protocol": "Proxy Protocol", "Proxy Server": "Proxy Server",