Files
uptime-kuma/server/notification-providers/pumble.js
Frank Elsinga 0f61d7ee1b chore: enable formatting over the entire codebase in CI (#6655)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-09 02:10:36 +01:00

50 lines
1.5 KiB
JavaScript

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 {
let config = this.getAxiosConfigWithProxy({});
if (heartbeatJSON === null && monitorJSON === null) {
let data = {
attachments: [
{
title: "Uptime Kuma Alert",
text: msg,
color: "#5BDD8B",
},
],
};
await axios.post(notification.webhookURL, data, config);
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, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Pumble;