mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-04-02 14:32:21 +00:00
feat: add notification provider PushPlus
(#5716)
Co-authored-by: Teror Fox <i@trfox.top> Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
parent
10a518e72e
commit
30f82b9cb4
5 changed files with 80 additions and 0 deletions
server
src/components
56
server/notification-providers/pushplus.js
Normal file
56
server/notification-providers/pushplus.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
const { DOWN, UP } = require("../../src/util");
|
||||||
|
|
||||||
|
class PushPlus extends NotificationProvider {
|
||||||
|
name = "PushPlus";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
* @param {BeanModel} notification Notification object
|
||||||
|
* @param {string} msg Message content
|
||||||
|
* @param {?object} monitorJSON Monitor details
|
||||||
|
* @param {?object} heartbeatJSON Heartbeat details
|
||||||
|
* @returns {Promise<string>} Success message
|
||||||
|
*/
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
const okMsg = "Sent Successfully.";
|
||||||
|
const url = "https://www.pushplus.plus/send";
|
||||||
|
try {
|
||||||
|
const config = {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const params = {
|
||||||
|
"token": notification.pushPlusSendKey,
|
||||||
|
"title": this.checkStatus(heartbeatJSON, monitorJSON),
|
||||||
|
"content": msg,
|
||||||
|
"template": "html"
|
||||||
|
};
|
||||||
|
await axios.post(url, params, config);
|
||||||
|
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 = PushPlus;
|
|
@ -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 PushPlus = require("./notification-providers/pushplus");
|
||||||
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");
|
||||||
|
@ -128,6 +129,7 @@ class Notification {
|
||||||
new Pushbullet(),
|
new Pushbullet(),
|
||||||
new PushDeer(),
|
new PushDeer(),
|
||||||
new Pushover(),
|
new Pushover(),
|
||||||
|
new PushPlus(),
|
||||||
new Pushy(),
|
new Pushy(),
|
||||||
new RocketChat(),
|
new RocketChat(),
|
||||||
new ServerChan(),
|
new ServerChan(),
|
||||||
|
|
|
@ -182,6 +182,7 @@ export default {
|
||||||
"SMSManager": "SmsManager (smsmanager.cz)",
|
"SMSManager": "SmsManager (smsmanager.cz)",
|
||||||
"WeCom": "WeCom (企业微信群机器人)",
|
"WeCom": "WeCom (企业微信群机器人)",
|
||||||
"ServerChan": "ServerChan (Server酱)",
|
"ServerChan": "ServerChan (Server酱)",
|
||||||
|
"PushPlus": "PushPlus (推送加)",
|
||||||
"smsc": "SMSC",
|
"smsc": "SMSC",
|
||||||
"WPush": "WPush(wpush.cn)",
|
"WPush": "WPush(wpush.cn)",
|
||||||
"YZJ": "YZJ (云之家自定义机器人)"
|
"YZJ": "YZJ (云之家自定义机器人)"
|
||||||
|
|
19
src/components/notifications/PushPlus.vue
Normal file
19
src/components/notifications/PushPlus.vue
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="pushPlus-sendkey" class="form-label">{{ $t("SendKey") }}</label>
|
||||||
|
<HiddenInput id="pushPlus-sendkey" v-model="$parent.notification.pushPlusSendKey" :required="true" autocomplete="new-password"></HiddenInput>
|
||||||
|
</div>
|
||||||
|
<i18n-t tag="div" keypath="More info on:" class="mb-3 form-text">
|
||||||
|
<a href="https://www.pushplus.plus/" target="_blank">https://www.pushplus.plus/</a>
|
||||||
|
</i18n-t>
|
||||||
|
</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 PushPlus from "./PushPlus.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,
|
||||||
|
"PushPlus": PushPlus,
|
||||||
"pushy": Pushy,
|
"pushy": Pushy,
|
||||||
"rocket.chat": RocketChat,
|
"rocket.chat": RocketChat,
|
||||||
"serwersms": SerwerSMS,
|
"serwersms": SerwerSMS,
|
||||||
|
|
Loading…
Add table
Reference in a new issue