mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-20 18:55:49 +08:00
Added Pumble Notification (#5781)
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
48
server/notification-providers/pumble.js
Normal file
48
server/notification-providers/pumble.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const NotificationProvider = require("./notification-provider");
|
||||
const axios = require("axios");
|
||||
const { UP } = require("../../src/util");
|
||||
|
||||
class Pumble extends NotificationProvider {
|
||||
name = "pumble";
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
try {
|
||||
if (heartbeatJSON === null && monitorJSON === null) {
|
||||
let data = {
|
||||
"attachments": [
|
||||
{
|
||||
"title": "Uptime Kuma Alert",
|
||||
"text": msg,
|
||||
"color": "#5BDD8B"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await axios.post(notification.webhookURL, data);
|
||||
return okMsg;
|
||||
}
|
||||
|
||||
let data = {
|
||||
"attachments": [
|
||||
{
|
||||
"title": `${monitorJSON["name"]} is ${heartbeatJSON["status"] === UP ? "up" : "down"}`,
|
||||
"text": heartbeatJSON["msg"],
|
||||
"color": (heartbeatJSON["status"] === UP ? "#5BDD8B" : "#DC3645"),
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
await axios.post(notification.webhookURL, data);
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Pumble;
|
Reference in New Issue
Block a user