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
9eb55be198
commit
ab68c35ad6
1 changed files with 13 additions and 8 deletions
|
@ -1,5 +1,6 @@
|
||||||
const NotificationProvider = require("./notification-provider");
|
const NotificationProvider = require("./notification-provider");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
const { DOWN, UP } = require("../../src/util");
|
||||||
|
|
||||||
class SpugPush extends NotificationProvider {
|
class SpugPush extends NotificationProvider {
|
||||||
|
|
||||||
|
@ -11,16 +12,20 @@ class SpugPush extends NotificationProvider {
|
||||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||||
let okMsg = "Sent Successfully.";
|
let okMsg = "Sent Successfully.";
|
||||||
try {
|
try {
|
||||||
await axios.post(`https://push.spug.cc/send/${notification.templateKey}`, {
|
let formData = {msg}
|
||||||
"status": heartbeatJSON["status"],
|
const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`;
|
||||||
"msg": heartbeatJSON["msg"],
|
if (heartbeatJSON == null) {
|
||||||
"duration": heartbeatJSON["duration"],
|
formData.title = "Uptime Kuma Message";
|
||||||
"name": monitorJSON["name"],
|
} else if (heartbeatJSON["status"] === UP) {
|
||||||
"target": this.extractAddress(monitorJSON),
|
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Up`;
|
||||||
});
|
formData.msg = `[✅ Up] ${heartbeatJSON["msg"]}`
|
||||||
|
} else if (heartbeatJSON["status"] === DOWN) {
|
||||||
|
formData.title = `UptimeKuma 「${monitorJSON["name"]}」 is Down`;
|
||||||
|
formData.msg = `[🔴 Down] ${heartbeatJSON["msg"]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
await axios.post(apiUrl, formData);
|
||||||
return okMsg;
|
return okMsg;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.throwGeneralAxiosError(error);
|
this.throwGeneralAxiosError(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue