mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-31 02:42: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 axios = require("axios");
|
||||
const { DOWN, UP } = require("../../src/util");
|
||||
|
||||
class SpugPush extends NotificationProvider {
|
||||
|
||||
|
@ -11,16 +12,20 @@ class SpugPush extends NotificationProvider {
|
|||
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.extractAddress(monitorJSON),
|
||||
});
|
||||
let formData = {msg}
|
||||
const apiUrl = `https://push.spug.cc/send/${notification.templateKey}`;
|
||||
if (heartbeatJSON == null) {
|
||||
formData.title = "Uptime Kuma Message";
|
||||
} else if (heartbeatJSON["status"] === UP) {
|
||||
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;
|
||||
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue