mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-04-27 18:56:25 -04:00
feat: Support YZJ notification provider (#5686)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
cf44d39e1b
commit
fce824f5a8
57
server/notification-providers/yzj.js
Normal file
57
server/notification-providers/yzj.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const { DOWN, UP } = require("../../src/util");
|
||||||
|
const { default: axios } = require("axios");
|
||||||
|
|
||||||
|
class YZJ extends NotificationProvider {
|
||||||
|
name = "YZJ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
let okMsg = "Sent Successfully.";
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (heartbeatJSON !== null) {
|
||||||
|
msg = `${this.statusToString(heartbeatJSON["status"])} ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const params = {
|
||||||
|
content: msg
|
||||||
|
};
|
||||||
|
// yzjtype=0 => general robot
|
||||||
|
const url = `${notification.yzjWebHookUrl}?yzjtype=0&yzjtoken=${notification.yzjToken}`;
|
||||||
|
|
||||||
|
const result = await axios.post(url, params, config);
|
||||||
|
if (!result.data?.success) {
|
||||||
|
throw new Error(result.data?.errmsg ?? "yzj's server did not respond with the expected result");
|
||||||
|
}
|
||||||
|
return okMsg;
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert status constant to string
|
||||||
|
* @param {string} status The status constant
|
||||||
|
* @returns {string} status
|
||||||
|
*/
|
||||||
|
statusToString(status) {
|
||||||
|
switch (status) {
|
||||||
|
case DOWN:
|
||||||
|
return "❌";
|
||||||
|
case UP:
|
||||||
|
return "✅";
|
||||||
|
default:
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = YZJ;
|
@ -69,6 +69,7 @@ const Cellsynt = require("./notification-providers/cellsynt");
|
|||||||
const Onesender = require("./notification-providers/onesender");
|
const Onesender = require("./notification-providers/onesender");
|
||||||
const Wpush = require("./notification-providers/wpush");
|
const Wpush = require("./notification-providers/wpush");
|
||||||
const SendGrid = require("./notification-providers/send-grid");
|
const SendGrid = require("./notification-providers/send-grid");
|
||||||
|
const YZJ = require("./notification-providers/yzj");
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
|
|
||||||
@ -154,7 +155,8 @@ class Notification {
|
|||||||
new GtxMessaging(),
|
new GtxMessaging(),
|
||||||
new Cellsynt(),
|
new Cellsynt(),
|
||||||
new Wpush(),
|
new Wpush(),
|
||||||
new SendGrid()
|
new SendGrid(),
|
||||||
|
new YZJ()
|
||||||
];
|
];
|
||||||
for (let item of list) {
|
for (let item of list) {
|
||||||
if (! item.name) {
|
if (! item.name) {
|
||||||
|
@ -183,6 +183,7 @@ export default {
|
|||||||
"ServerChan": "ServerChan (Server酱)",
|
"ServerChan": "ServerChan (Server酱)",
|
||||||
"smsc": "SMSC",
|
"smsc": "SMSC",
|
||||||
"WPush": "WPush(wpush.cn)",
|
"WPush": "WPush(wpush.cn)",
|
||||||
|
"YZJ": "YZJ (云之家自定义机器人)"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sort by notification name
|
// Sort by notification name
|
||||||
|
19
src/components/notifications/YZJ.vue
Normal file
19
src/components/notifications/YZJ.vue
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="yzjWebHookUrl" class="form-label">{{ $t("YZJ Webhook URL") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<input id="yzjWebHookUrl" v-model="$parent.notification.yzjWebHookUrl" type="url" class="form-control" required />
|
||||||
|
<i18n-t class="form-text" keypath="wayToGetTeamsURL">
|
||||||
|
<a href="https://www.yunzhijia.com/opendocs/docs.html#/tutorial/index/robot" target="_blank">{{ $t("here") }}</a>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="yzjToken" class="form-label">{{ $t("YZJ Robot Token") }}<span style="color: red;"><sup>*</sup></span></label>
|
||||||
|
<HiddenInput id="yzjToken" v-model="$parent.notification.yzjToken" :required="true" autocomplete="new-password"></HiddenInput>
|
||||||
|
<i18n-t class="form-text" keypath="wayToGetLineNotifyToken">
|
||||||
|
<a href="https://www.yunzhijia.com/opendocs/docs.html#/server-api/im/index?id=%e6%8e%a5%e5%8f%a3%e5%9c%b0%e5%9d%80%e5%92%8c%e6%8e%88%e6%9d%83%e7%a0%81" target="_blank">{{ $t("here") }}</a>
|
||||||
|
</i18n-t>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
</script>
|
@ -67,6 +67,7 @@ import Cellsynt from "./Cellsynt.vue";
|
|||||||
import WPush from "./WPush.vue";
|
import WPush from "./WPush.vue";
|
||||||
import SIGNL4 from "./SIGNL4.vue";
|
import SIGNL4 from "./SIGNL4.vue";
|
||||||
import SendGrid from "./SendGrid.vue";
|
import SendGrid from "./SendGrid.vue";
|
||||||
|
import YZJ from "./YZJ.vue";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage all notification form.
|
* Manage all notification form.
|
||||||
@ -142,6 +143,7 @@ const NotificationFormList = {
|
|||||||
"Cellsynt": Cellsynt,
|
"Cellsynt": Cellsynt,
|
||||||
"WPush": WPush,
|
"WPush": WPush,
|
||||||
"SendGrid": SendGrid,
|
"SendGrid": SendGrid,
|
||||||
|
"YZJ": YZJ,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NotificationFormList;
|
export default NotificationFormList;
|
||||||
|
@ -1051,5 +1051,7 @@
|
|||||||
"RabbitMQ Password": "RabbitMQ Password",
|
"RabbitMQ Password": "RabbitMQ Password",
|
||||||
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
|
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
|
||||||
"SendGrid API Key": "SendGrid API Key",
|
"SendGrid API Key": "SendGrid API Key",
|
||||||
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas"
|
"Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
|
||||||
|
"YZJ Webhook URL": "YZJ Webhook URL",
|
||||||
|
"YZJ Robot Token": "YZJ Robot token"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user