mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-13 04:44:46 +00:00
Compare commits
5 commits
4c211382ec
...
27488a17fe
Author | SHA1 | Date | |
---|---|---|---|
|
27488a17fe | ||
|
b023a81d7b | ||
|
b84b79b021 | ||
|
b0910138f3 | ||
|
7add28ebd9 |
3 changed files with 29 additions and 5 deletions
|
@ -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)) {
|
||||
|
|
|
@ -19,8 +19,18 @@
|
|||
<select id="mentioning" v-model="$parent.notification.mentioning" class="form-select" required>
|
||||
<option value="nobody">{{ $t("Don't mention people") }}</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>
|
||||
</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>
|
||||
|
||||
<script lang="ts">
|
||||
|
|
|
@ -687,6 +687,10 @@
|
|||
"Mentioning": "Mentioning",
|
||||
"Don't mention people": "Don't mention people",
|
||||
"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",
|
||||
"Platform": "Platform",
|
||||
"Huawei": "Huawei",
|
||||
|
|
Loading…
Add table
Reference in a new issue