uptime-kuma/server/notification-providers/stackfield.js
Sophie Hirn 216f39d556
Replace monitorJSON.name with monitorJSON.pathName in all notification providers (where applicable)
As noted in #3798, it would be great to have the alarm notification include
the full monitor path.  This was done for Mattermost in #3801, but not for
the other notification providers.  This commit replaces all other trivial
occurences of monitorJSON.name with monitorJSON.pathName.
2024-12-30 14:47:57 +01:00

44 lines
1.2 KiB
JavaScript

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { setting } = require("../util-server");
const { getMonitorRelativeURL } = require("../../src/util");
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.pathName) {
textMsg += `\n*${monitorJSON.pathName}*`;
}
textMsg += `\n${msg}`;
const baseURL = await setting("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;