feat(notification): add WeCom mentioned mobile list support" (#6758)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
30ee8cec1f
commit
a0d73aba1a
@ -18,7 +18,7 @@ class WeCom extends NotificationProvider {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
config = this.getAxiosConfigWithProxy(config);
|
config = this.getAxiosConfigWithProxy(config);
|
||||||
let body = this.composeMessage(heartbeatJSON, msg);
|
let body = this.composeMessage(notification, heartbeatJSON, msg);
|
||||||
await axios.post(
|
await axios.post(
|
||||||
`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${notification.weComBotKey}`,
|
`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${notification.weComBotKey}`,
|
||||||
body,
|
body,
|
||||||
@ -32,11 +32,12 @@ class WeCom extends NotificationProvider {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the message to send
|
* Generate the message to send
|
||||||
|
* @param {object} notification Notification configuration
|
||||||
* @param {object} heartbeatJSON Heartbeat details (For Up/Down only)
|
* @param {object} heartbeatJSON Heartbeat details (For Up/Down only)
|
||||||
* @param {string} msg General message
|
* @param {string} msg General message
|
||||||
* @returns {object} Message
|
* @returns {object} Message
|
||||||
*/
|
*/
|
||||||
composeMessage(heartbeatJSON, msg) {
|
composeMessage(notification, heartbeatJSON, msg) {
|
||||||
let title = "UptimeKuma Message";
|
let title = "UptimeKuma Message";
|
||||||
if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === UP) {
|
if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === UP) {
|
||||||
title = "UptimeKuma Monitor Up";
|
title = "UptimeKuma Monitor Up";
|
||||||
@ -44,11 +45,26 @@ class WeCom extends NotificationProvider {
|
|||||||
if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
|
if (msg != null && heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
|
||||||
title = "UptimeKuma Monitor 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 {
|
return {
|
||||||
msgtype: "text",
|
msgtype: "text",
|
||||||
text: {
|
text: textObj,
|
||||||
content: title + "\n" + msg,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,4 +23,16 @@
|
|||||||
</a>
|
</a>
|
||||||
</i18n-t>
|
</i18n-t>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="wecom-mentioned-mobile-list" class="form-label">{{ $t("WeCom Mentioned Mobile List") }}</label>
|
||||||
|
<input
|
||||||
|
id="wecom-mentioned-mobile-list"
|
||||||
|
v-model="$parent.notification.weComMentionedMobileList"
|
||||||
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
placeholder="13800001111,13900002222,@all"
|
||||||
|
/>
|
||||||
|
<p class="form-text">{{ $t("WeCom Mentioned Mobile List Description") }}</p>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -793,6 +793,8 @@
|
|||||||
"Retry": "Retry",
|
"Retry": "Retry",
|
||||||
"Topic": "Topic",
|
"Topic": "Topic",
|
||||||
"WeCom Bot Key": "WeCom Bot Key",
|
"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",
|
"Setup Proxy": "Set Up Proxy",
|
||||||
"Proxy Protocol": "Proxy Protocol",
|
"Proxy Protocol": "Proxy Protocol",
|
||||||
"Proxy Server": "Proxy Server",
|
"Proxy Server": "Proxy Server",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user