Compare commits

...

7 commits

Author SHA1 Message Date
xx
4c211382ec
Merge b023a81d7b into be2faf64ce 2024-12-22 05:46:25 +00:00
Louis Lam
be2faf64ce
Clarify that BSD OSs are not supported (#5465)
Some checks failed
validate / json-yaml-validate (push) Has been cancelled
validate / validate (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
2024-12-22 13:46:13 +08:00
Louis Lam
0b76e19401
Clarify that BSD OSs are not supported 2024-12-22 13:45:19 +08:00
xx
b023a81d7b fix: checks 2024-12-21 15:30:06 +08:00
xx
b84b79b021 lint: fix style 2024-12-21 15:11:59 +08:00
xx
b0910138f3 format: format code 2024-12-21 14:56:15 +08:00
xx
7add28ebd9 feat: improve dingtalk webhook mention
add mention specify
2024-12-21 14:42:34 +08:00
4 changed files with 30 additions and 5 deletions

View file

@ -62,6 +62,7 @@ Requirements:
- Platform - Platform
- ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc. - ✅ Major Linux distros such as Debian, Ubuntu, CentOS, Fedora and ArchLinux etc.
- ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher - ✅ Windows 10 (x64), Windows Server 2012 R2 (x64) or higher
- ❌ FreeBSD / OpenBSD / NetBSD
- ❌ Replit / Heroku - ❌ Replit / Heroku
- [Node.js](https://nodejs.org/en/download/) 18 / 20.4 - [Node.js](https://nodejs.org/en/download/) 18 / 20.4
- [npm](https://docs.npmjs.com/cli/) 9 - [npm](https://docs.npmjs.com/cli/) 9

View file

@ -11,17 +11,22 @@ 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(" ");
try { try {
if (heartbeatJSON != null) { if (heartbeatJSON != null) {
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 +36,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)) {

View file

@ -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 v-if="$parent.notification.mentioning === 'specify-mobiles'" class="mb-3">
<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 v-if="$parent.notification.mentioning === 'specify-users'" class="mb-3">
<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">

View file

@ -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",