mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-01 11:22:34 +02:00
Add SpugPush notification provider
This commit is contained in:
parent
8396330552
commit
fc8edf0618
6 changed files with 73 additions and 0 deletions
48
server/notification-providers/spugpush.js
Normal file
48
server/notification-providers/spugpush.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
const NotificationProvider = require("./notification-provider");
|
||||||
|
const axios = require("axios");
|
||||||
|
|
||||||
|
class SpugPush extends NotificationProvider {
|
||||||
|
|
||||||
|
name = "SpugPush";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
|
let okMsg = "Sent Successfully.";
|
||||||
|
try {
|
||||||
|
await axios.post(`https://push.spug.cc/send/${notification.templateKey}`, {
|
||||||
|
"status": heartbeatJSON["status"],
|
||||||
|
"msg": heartbeatJSON["msg"],
|
||||||
|
"duration": heartbeatJSON["duration"],
|
||||||
|
"name": monitorJSON["name"],
|
||||||
|
"target": this.getTarget(monitorJSON),
|
||||||
|
});
|
||||||
|
|
||||||
|
return okMsg;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
this.throwGeneralAxiosError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the formatted target for message
|
||||||
|
* @param {object} monitorJSON Monitor details (For Up/Down only)
|
||||||
|
* @returns {string} Formatted target
|
||||||
|
*/
|
||||||
|
getTarget(monitorJSON) {
|
||||||
|
let target = "-";
|
||||||
|
if (monitorJSON["hostname"]) {
|
||||||
|
target = monitorJSON["hostname"];
|
||||||
|
if (monitorJSON["port"]) {
|
||||||
|
target += ":" + monitorJSON["port"];
|
||||||
|
}
|
||||||
|
} else if (monitorJSON["url"]) {
|
||||||
|
target = monitorJSON["url"];
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = SpugPush;
|
|
@ -75,6 +75,7 @@ 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");
|
const YZJ = require("./notification-providers/yzj");
|
||||||
const SMSPlanet = require("./notification-providers/sms-planet");
|
const SMSPlanet = require("./notification-providers/sms-planet");
|
||||||
|
const SpugPush = require("./notification-providers/spugpush");
|
||||||
|
|
||||||
class Notification {
|
class Notification {
|
||||||
|
|
||||||
|
@ -167,6 +168,7 @@ class Notification {
|
||||||
new SendGrid(),
|
new SendGrid(),
|
||||||
new YZJ(),
|
new YZJ(),
|
||||||
new SMSPlanet(),
|
new SMSPlanet(),
|
||||||
|
new SpugPush(),
|
||||||
];
|
];
|
||||||
for (let item of list) {
|
for (let item of list) {
|
||||||
if (! item.name) {
|
if (! item.name) {
|
||||||
|
|
|
@ -185,6 +185,7 @@ export default {
|
||||||
"WeCom": "WeCom (企业微信群机器人)",
|
"WeCom": "WeCom (企业微信群机器人)",
|
||||||
"ServerChan": "ServerChan (Server酱)",
|
"ServerChan": "ServerChan (Server酱)",
|
||||||
"PushPlus": "PushPlus (推送加)",
|
"PushPlus": "PushPlus (推送加)",
|
||||||
|
"SpugPush": "SpugPush(Spug推送助手)",
|
||||||
"smsc": "SMSC",
|
"smsc": "SMSC",
|
||||||
"WPush": "WPush(wpush.cn)",
|
"WPush": "WPush(wpush.cn)",
|
||||||
"YZJ": "YZJ (云之家自定义机器人)",
|
"YZJ": "YZJ (云之家自定义机器人)",
|
||||||
|
|
19
src/components/notifications/SpugPush.vue
Normal file
19
src/components/notifications/SpugPush.vue
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<template>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="spugpush-templateKey" class="form-label">{{ $t("SpugPush Template Code") }}</label>
|
||||||
|
<HiddenInput id="spugpush-templateKey" v-model="$parent.notification.templateKey" :required="true" autocomplete="new-password"></HiddenInput>
|
||||||
|
</div>
|
||||||
|
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
|
||||||
|
<a href="https://push.spug.cc/guide/plugin/kuma" rel="noopener noreferrer" target="_blank">https://push.spug.cc</a>
|
||||||
|
</i18n-t>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import HiddenInput from "../HiddenInput.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
HiddenInput,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
|
@ -64,6 +64,7 @@ import WeCom from "./WeCom.vue";
|
||||||
import GoAlert from "./GoAlert.vue";
|
import GoAlert from "./GoAlert.vue";
|
||||||
import ZohoCliq from "./ZohoCliq.vue";
|
import ZohoCliq from "./ZohoCliq.vue";
|
||||||
import Splunk from "./Splunk.vue";
|
import Splunk from "./Splunk.vue";
|
||||||
|
import SpugPush from "./SpugPush.vue";
|
||||||
import SevenIO from "./SevenIO.vue";
|
import SevenIO from "./SevenIO.vue";
|
||||||
import Whapi from "./Whapi.vue";
|
import Whapi from "./Whapi.vue";
|
||||||
import WAHA from "./WAHA.vue";
|
import WAHA from "./WAHA.vue";
|
||||||
|
@ -140,6 +141,7 @@ const NotificationFormList = {
|
||||||
"threema": Threema,
|
"threema": Threema,
|
||||||
"twilio": Twilio,
|
"twilio": Twilio,
|
||||||
"Splunk": Splunk,
|
"Splunk": Splunk,
|
||||||
|
"SpugPush": SpugPush,
|
||||||
"webhook": Webhook,
|
"webhook": Webhook,
|
||||||
"WeCom": WeCom,
|
"WeCom": WeCom,
|
||||||
"GoAlert": GoAlert,
|
"GoAlert": GoAlert,
|
||||||
|
|
|
@ -798,6 +798,7 @@
|
||||||
"PushDeer Server": "PushDeer Server",
|
"PushDeer Server": "PushDeer Server",
|
||||||
"pushDeerServerDescription": "Leave blank to use the official server",
|
"pushDeerServerDescription": "Leave blank to use the official server",
|
||||||
"PushDeer Key": "PushDeer Key",
|
"PushDeer Key": "PushDeer Key",
|
||||||
|
"SpugPush Template Code": "Template Code",
|
||||||
"wayToGetClickSendSMSToken": "You can get API Username and API Key from {0} .",
|
"wayToGetClickSendSMSToken": "You can get API Username and API Key from {0} .",
|
||||||
"Custom Monitor Type": "Custom Monitor Type",
|
"Custom Monitor Type": "Custom Monitor Type",
|
||||||
"Google Analytics ID": "Google Analytics ID",
|
"Google Analytics ID": "Google Analytics ID",
|
||||||
|
|
Loading…
Add table
Reference in a new issue