You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const axios = require("axios");
|
|
|
|
const { getMonitorRelativeURL } = require("../../src/util");
|
|
|
|
const { Settings } = require("../settings");
|
|
|
|
|
|
|
|
class Stackfield extends NotificationProvider {
|
|
|
|
name = "stackfield";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
|
|
|
const okMsg = "Sent Successfully.";
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Stackfield message formatting: https://www.stackfield.com/help/formatting-messages-2001
|
|
|
|
|
|
|
|
let textMsg = "+Uptime Kuma Alert+";
|
|
|
|
|
|
|
|
if (monitorJSON && monitorJSON.name) {
|
|
|
|
textMsg += `\n*${monitorJSON.name}*`;
|
|
|
|
}
|
|
|
|
|
|
|
|
textMsg += `\n${msg}`;
|
|
|
|
|
|
|
|
const baseURL = await Settings.get("primaryBaseURL");
|
|
|
|
if (baseURL) {
|
|
|
|
textMsg += `\n${baseURL + getMonitorRelativeURL(monitorJSON.id)}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
"Title": textMsg,
|
|
|
|
};
|
|
|
|
|
|
|
|
await axios.post(notification.stackfieldwebhookURL, data);
|
|
|
|
return okMsg;
|
|
|
|
} catch (error) {
|
|
|
|
this.throwGeneralAxiosError(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Stackfield;
|