mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-03-13 04:44:46 +00:00
Merge b023a81d7b
into be2faf64ce
This commit is contained in:
commit
4c211382ec
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) {
|
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)) {
|
||||||
|
|
|
@ -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">
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Add table
Reference in a new issue