mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-22 19:45:56 +00:00
feat: improve dingtalk webhook mention
add mention specify
This commit is contained in:
parent
fd55659c2b
commit
7add28ebd9
6 changed files with 48 additions and 6 deletions
|
@ -11,17 +11,26 @@ class DingDing extends NotificationProvider {
|
||||||
*/
|
*/
|
||||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
const okMsg = "Sent Successfully.";
|
const okMsg = "Sent Successfully.";
|
||||||
|
const mentionAll = notification.mentioning === "everyone"
|
||||||
|
const mobileList = notification.mentioning === "specify-mobiles" ? notification.mobileList.split(",") : []
|
||||||
|
const userList = notification.mentioning === "specify-users" ? notification.userList.split(",") : []
|
||||||
|
const mentionStr = [...mobileList || [], ...userList || [] ].map(item => `@${item}`).join(" ")
|
||||||
|
console.log('mobileList: ',mobileList)
|
||||||
|
console.log('userList: ',userList)
|
||||||
|
console.log('mentionStr: ',mentionStr)
|
||||||
try {
|
try {
|
||||||
if (heartbeatJSON != null) {
|
if (heartbeatJSON != null) {
|
||||||
|
notification.mobileList
|
||||||
let params = {
|
let params = {
|
||||||
msgtype: "markdown",
|
msgtype: "markdown",
|
||||||
markdown: {
|
markdown: {
|
||||||
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}`,
|
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}`,
|
||||||
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
|
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}${'\n\n'+mentionStr}`,
|
||||||
},
|
},
|
||||||
"at": {
|
at: {
|
||||||
"isAtAll": notification.mentioning === "everyone"
|
isAtAll: mentionAll,
|
||||||
|
atUserIds: userList,
|
||||||
|
atMobiles: mobileList
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (await this.sendToDingDing(notification, params)) {
|
if (await this.sendToDingDing(notification, params)) {
|
||||||
|
@ -31,7 +40,12 @@ class DingDing extends NotificationProvider {
|
||||||
let params = {
|
let params = {
|
||||||
msgtype: "text",
|
msgtype: "text",
|
||||||
text: {
|
text: {
|
||||||
content: msg
|
content: `${msg}${'\n'+mentionStr}`
|
||||||
|
},
|
||||||
|
at: {
|
||||||
|
isAtAll: mentionAll,
|
||||||
|
atUserIds: userList,
|
||||||
|
atMobiles: mobileList
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (await this.sendToDingDing(notification, params)) {
|
if (await this.sendToDingDing(notification, params)) {
|
||||||
|
|
|
@ -19,8 +19,18 @@
|
||||||
<select id="mentioning" v-model="$parent.notification.mentioning" class="form-select" required>
|
<select id="mentioning" v-model="$parent.notification.mentioning" class="form-select" required>
|
||||||
<option value="nobody">{{ $t("Don't mention people") }}</option>
|
<option value="nobody">{{ $t("Don't mention people") }}</option>
|
||||||
<option value="everyone">{{ $t("Mention group", { group: "@everyone" }) }}</option>
|
<option value="everyone">{{ $t("Mention group", { group: "@everyone" }) }}</option>
|
||||||
|
<option value="specify-mobiles">{{ $t("Mention Mobile List") }}</option>
|
||||||
|
<option value="specify-users">{{ $t("Mention User List") }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3" v-if="$parent.notification.mentioning === 'specify-mobiles'">
|
||||||
|
<label for="mobileList" class="form-label">{{ $t("Dingtalk Mobile List") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<input id="mobileList" v-model="$parent.notification.mobileList" type="list" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3" v-if="$parent.notification.mentioning === 'specify-users'">
|
||||||
|
<label for="userList" class="form-label">{{ $t("Dingtalk User List") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<input id="userList" v-model="$parent.notification.userList" type="list" class="form-control" required>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
|
@ -687,6 +687,10 @@
|
||||||
"Mentioning": "Mentioning",
|
"Mentioning": "Mentioning",
|
||||||
"Don't mention people": "Don't mention people",
|
"Don't mention people": "Don't mention people",
|
||||||
"Mention group": "Mention {group}",
|
"Mention group": "Mention {group}",
|
||||||
|
"Mention Mobile List": "Mention mobile list",
|
||||||
|
"Mention User List": "Mention user ID List",
|
||||||
|
"Dingtalk Mobile List": "Mobile List (use comma separator)",
|
||||||
|
"Dingtalk User List": "User List (use comma separator)",
|
||||||
"Device Token": "Device Token",
|
"Device Token": "Device Token",
|
||||||
"Platform": "Platform",
|
"Platform": "Platform",
|
||||||
"Huawei": "Huawei",
|
"Huawei": "Huawei",
|
||||||
|
|
|
@ -949,6 +949,10 @@
|
||||||
"Mentioning": "是否提及成员",
|
"Mentioning": "是否提及成员",
|
||||||
"Don't mention people": "不提及任何人",
|
"Don't mention people": "不提及任何人",
|
||||||
"Mention group": "提及 {group}",
|
"Mention group": "提及 {group}",
|
||||||
|
"Mention Mobile List": "提及指定手机号列表",
|
||||||
|
"Mention User List": "提及指定用户ID列表",
|
||||||
|
"Dingtalk Mobile List": "手机号列表(使用逗号分隔多个手机号)",
|
||||||
|
"Dingtalk User List": "用户ID列表(使用逗号分隔多个用户ID)",
|
||||||
"senderSevenIO": "发信人号码或名称",
|
"senderSevenIO": "发信人号码或名称",
|
||||||
"wayToGetSevenIOApiKey": "访问 app.seven.io > 开发人员 > api 密钥 > 绿色添加按钮下的仪表板",
|
"wayToGetSevenIOApiKey": "访问 app.seven.io > 开发人员 > api 密钥 > 绿色添加按钮下的仪表板",
|
||||||
"receiverInfoSevenIO": "如果接收号码不在德国,您必须在号码前面添加国家代码(例如,对于来自美国的国家代码 1,请使用 117612121212 而不是 017612121212)",
|
"receiverInfoSevenIO": "如果接收号码不在德国,您必须在号码前面添加国家代码(例如,对于来自美国的国家代码 1,请使用 117612121212 而不是 017612121212)",
|
||||||
|
|
|
@ -760,5 +760,11 @@
|
||||||
"locally configured mail transfer agent": "本機設定的郵件傳輸代理",
|
"locally configured mail transfer agent": "本機設定的郵件傳輸代理",
|
||||||
"now": "現在",
|
"now": "現在",
|
||||||
"time ago": "{0} 之前",
|
"time ago": "{0} 之前",
|
||||||
"ignoreTLSErrorGeneral": "忽略連接中的TLS/SSL錯誤"
|
"ignoreTLSErrorGeneral": "忽略連接中的TLS/SSL錯誤",
|
||||||
|
"Don't mention people": "不提及任何人",
|
||||||
|
"Mention group": "提及 {group}",
|
||||||
|
"Mention Mobile List": "提及指定手機號",
|
||||||
|
"Mention User List": "提及指定用戶ID",
|
||||||
|
"Dingtalk Mobile List": "手機號列表(使用逗號分割多个手機號)",
|
||||||
|
"Dingtalk User List": "用戶ID列表(使用逗號分割多個用戶ID)"
|
||||||
}
|
}
|
||||||
|
|
|
@ -956,6 +956,10 @@
|
||||||
"wayToGetDiscordThreadId": "取得主題 / 論壇文章 ID 與取得頻道 ID 類似。詳細了解如何取得 ID {0}",
|
"wayToGetDiscordThreadId": "取得主題 / 論壇文章 ID 與取得頻道 ID 類似。詳細了解如何取得 ID {0}",
|
||||||
"Don't mention people": "不要提及他人",
|
"Don't mention people": "不要提及他人",
|
||||||
"Mention group": "提及 {group}",
|
"Mention group": "提及 {group}",
|
||||||
|
"Mention Mobile List": "提及指定手機號",
|
||||||
|
"Mention User List": "提及指定用戶ID",
|
||||||
|
"Dingtalk Mobile List": "手機號列表(使用逗號分割多个手機號)",
|
||||||
|
"Dingtalk User List": "用戶ID列表(使用逗號分割多個用戶ID)",
|
||||||
"smspartnerSenderNameInfo": "必須介於 3..=11 個字元之間",
|
"smspartnerSenderNameInfo": "必須介於 3..=11 個字元之間",
|
||||||
"cacheBusterParam": "新增 {0} 參數",
|
"cacheBusterParam": "新增 {0} 參數",
|
||||||
"cacheBusterParamDescription": "隨機生成參數以跳過快取。",
|
"cacheBusterParamDescription": "隨機生成參數以跳過快取。",
|
||||||
|
|
Loading…
Add table
Reference in a new issue