diff --git a/server/notification-providers/dingding.js b/server/notification-providers/dingding.js index c66f270a7..79b0605a6 100644 --- a/server/notification-providers/dingding.js +++ b/server/notification-providers/dingding.js @@ -11,17 +11,22 @@ class DingDing extends NotificationProvider { */ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { 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(" "); try { if (heartbeatJSON != null) { let params = { msgtype: "markdown", markdown: { 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": { - "isAtAll": notification.mentioning === "everyone" + at: { + isAtAll: mentionAll, + atUserIds: userList, + atMobiles: mobileList } }; if (await this.sendToDingDing(notification, params)) { @@ -31,7 +36,12 @@ class DingDing extends NotificationProvider { let params = { msgtype: "text", text: { - content: msg + content: `${msg}${"\n" + mentionStr}` + }, + at: { + isAtAll: mentionAll, + atUserIds: userList, + atMobiles: mobileList } }; if (await this.sendToDingDing(notification, params)) { diff --git a/src/components/notifications/DingDing.vue b/src/components/notifications/DingDing.vue index 710677fd7..f6012818b 100644 --- a/src/components/notifications/DingDing.vue +++ b/src/components/notifications/DingDing.vue @@ -19,8 +19,18 @@ +