mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-20 20:46:08 +08:00
Add SpugPush notification provider (#5813)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
37
server/notification-providers/spugpush.js
Normal file
37
server/notification-providers/spugpush.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { DOWN, UP } = require("../../src/util");
|
||||
|
||||
class SpugPush extends NotificationProvider {
|
||||
|
||||
name = "SpugPush";
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
let okMsg = "Sent Successfully.";
|
||||
try {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SpugPush;
|
Reference in New Issue
Block a user