mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 19:32:34 +02: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
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 Pushbullet = require("./notification-providers/pushbullet");
|
||||||
const PushDeer = require("./notification-providers/pushdeer");
|
const PushDeer = require("./notification-providers/pushdeer");
|
||||||
const Pushover = require("./notification-providers/pushover");
|
const Pushover = require("./notification-providers/pushover");
|
||||||
|
const PushPlusPlus = require("./notification-providers/pushplusplus");
|
||||||
const Pushy = require("./notification-providers/pushy");
|
const Pushy = require("./notification-providers/pushy");
|
||||||
const RocketChat = require("./notification-providers/rocket-chat");
|
const RocketChat = require("./notification-providers/rocket-chat");
|
||||||
const SerwerSMS = require("./notification-providers/serwersms");
|
const SerwerSMS = require("./notification-providers/serwersms");
|
||||||
|
@ -158,7 +159,8 @@ class Notification {
|
||||||
new Cellsynt(),
|
new Cellsynt(),
|
||||||
new Wpush(),
|
new Wpush(),
|
||||||
new SendGrid(),
|
new SendGrid(),
|
||||||
new YZJ()
|
new YZJ(),
|
||||||
|
new PushPlusPlus()
|
||||||
];
|
];
|
||||||
for (let item of list) {
|
for (let item of list) {
|
||||||
if (! item.name) {
|
if (! item.name) {
|
||||||
|
|
|
@ -182,6 +182,7 @@ export default {
|
||||||
"SMSManager": "SmsManager (smsmanager.cz)",
|
"SMSManager": "SmsManager (smsmanager.cz)",
|
||||||
"WeCom": "WeCom (企业微信群机器人)",
|
"WeCom": "WeCom (企业微信群机器人)",
|
||||||
"ServerChan": "ServerChan (Server酱)",
|
"ServerChan": "ServerChan (Server酱)",
|
||||||
|
"PushPlusPlus": "PushPlusPlus(推送加)",
|
||||||
"smsc": "SMSC",
|
"smsc": "SMSC",
|
||||||
"WPush": "WPush(wpush.cn)",
|
"WPush": "WPush(wpush.cn)",
|
||||||
"YZJ": "YZJ (云之家自定义机器人)"
|
"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 Pushbullet from "./Pushbullet.vue";
|
||||||
import PushDeer from "./PushDeer.vue";
|
import PushDeer from "./PushDeer.vue";
|
||||||
import Pushover from "./Pushover.vue";
|
import Pushover from "./Pushover.vue";
|
||||||
|
import PushPlusPlus from "./PushPlusPlus.vue";
|
||||||
import Pushy from "./Pushy.vue";
|
import Pushy from "./Pushy.vue";
|
||||||
import RocketChat from "./RocketChat.vue";
|
import RocketChat from "./RocketChat.vue";
|
||||||
import ServerChan from "./ServerChan.vue";
|
import ServerChan from "./ServerChan.vue";
|
||||||
|
@ -116,6 +117,7 @@ const NotificationFormList = {
|
||||||
"PushByTechulus": TechulusPush,
|
"PushByTechulus": TechulusPush,
|
||||||
"PushDeer": PushDeer,
|
"PushDeer": PushDeer,
|
||||||
"pushover": Pushover,
|
"pushover": Pushover,
|
||||||
|
"pushplusplus": PushPlusPlus,
|
||||||
"pushy": Pushy,
|
"pushy": Pushy,
|
||||||
"rocket.chat": RocketChat,
|
"rocket.chat": RocketChat,
|
||||||
"serwersms": SerwerSMS,
|
"serwersms": SerwerSMS,
|
||||||
|
|
Loading…
Add table
Reference in a new issue