mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-04-02 06:22:20 +00:00
feat(notification): 新增 PushPlusPlus 通知支持
- 在 notification.js 中添加 PushPlusPlus 通知提供商 - 在 NotificationDialog.vue 中添加 PushPlusPlus 选项 - 在 notifications/index.js 中导入并注册 PushPlusPlus 组件
This commit is contained in:
parent
f50e26edd6
commit
6f72ddbb72
5 changed files with 64 additions and 1 deletions
server
src/components
42
server/notification-providers/pushplusplus.js
Normal file
42
server/notification-providers/pushplusplus.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { DOWN, UP } = require("../../src/util");
|
||||
|
||||
class PushPlusPlus extends NotificationProvider {
|
||||
name = "PushPlusPlus";
|
||||
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
const url = `https://pushplus.plus/send`;
|
||||
try {
|
||||
await axios.post(notification.pushPlusPlusToken, {
|
||||
"title": this.checkStatus(heartbeatJSON, monitorJSON),
|
||||
"content": msg,
|
||||
});
|
||||
|
||||
return okMsg;
|
||||
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted title for message
|
||||
* @param {?object} heartbeatJSON Heartbeat details (For Up/Down only)
|
||||
* @param {?object} monitorJSON Monitor details (For Up/Down only)
|
||||
* @returns {string} Formatted title
|
||||
*/
|
||||
checkStatus(heartbeatJSON, monitorJSON) {
|
||||
let title = "UptimeKuma Message";
|
||||
if (heartbeatJSON != null && heartbeatJSON["status"] === UP) {
|
||||
title = "UptimeKuma Monitor Up " + monitorJSON["name"];
|
||||
}
|
||||
if (heartbeatJSON != null && heartbeatJSON["status"] === DOWN) {
|
||||
title = "UptimeKuma Monitor Down " + monitorJSON["name"];
|
||||
}
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PushPlusPlus;
|
|
@ -39,6 +39,7 @@ const PromoSMS = require("./notification-providers/promosms");
|
|||
const Pushbullet = require("./notification-providers/pushbullet");
|
||||
const PushDeer = require("./notification-providers/pushdeer");
|
||||
const Pushover = require("./notification-providers/pushover");
|
||||
const PushPlusPlus = require("./notification-providers/pushplusplus");
|
||||
const Pushy = require("./notification-providers/pushy");
|
||||
const RocketChat = require("./notification-providers/rocket-chat");
|
||||
const SerwerSMS = require("./notification-providers/serwersms");
|
||||
|
@ -158,7 +159,8 @@ class Notification {
|
|||
new Cellsynt(),
|
||||
new Wpush(),
|
||||
new SendGrid(),
|
||||
new YZJ()
|
||||
new YZJ(),
|
||||
new PushPlusPlus()
|
||||
];
|
||||
for (let item of list) {
|
||||
if (! item.name) {
|
||||
|
|
|
@ -182,6 +182,7 @@ export default {
|
|||
"SMSManager": "SmsManager (smsmanager.cz)",
|
||||
"WeCom": "WeCom (企业微信群机器人)",
|
||||
"ServerChan": "ServerChan (Server酱)",
|
||||
"PushPlusPlus": "PushPlusPlus(推送加)",
|
||||
"smsc": "SMSC",
|
||||
"WPush": "WPush(wpush.cn)",
|
||||
"YZJ": "YZJ (云之家自定义机器人)"
|
||||
|
|
16
src/components/notifications/PushPlusPlus.vue
Normal file
16
src/components/notifications/PushPlusPlus.vue
Normal file
|
@ -0,0 +1,16 @@
|
|||
<template>
|
||||
<div class="mb-3">
|
||||
<label for="pushplusplus-sendkey" class="form-label">{{ $t("SendKey") }}</label>
|
||||
<HiddenInput id="pushplusplus-sendkey" v-model="$parent.notification.pushPlusPlusSendKey" :required="true" autocomplete="new-password"></HiddenInput>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HiddenInput from "../HiddenInput.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HiddenInput,
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -39,6 +39,7 @@ import PromoSMS from "./PromoSMS.vue";
|
|||
import Pushbullet from "./Pushbullet.vue";
|
||||
import PushDeer from "./PushDeer.vue";
|
||||
import Pushover from "./Pushover.vue";
|
||||
import PushPlusPlus from "./PushPlusPlus.vue";
|
||||
import Pushy from "./Pushy.vue";
|
||||
import RocketChat from "./RocketChat.vue";
|
||||
import ServerChan from "./ServerChan.vue";
|
||||
|
@ -116,6 +117,7 @@ const NotificationFormList = {
|
|||
"PushByTechulus": TechulusPush,
|
||||
"PushDeer": PushDeer,
|
||||
"pushover": Pushover,
|
||||
"pushplusplus": PushPlusPlus,
|
||||
"pushy": Pushy,
|
||||
"rocket.chat": RocketChat,
|
||||
"serwersms": SerwerSMS,
|
||||
|
|
Loading…
Add table
Reference in a new issue