mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-20 21:24:44 -05:00
8a92054c2b
* Added JSDoc to eslint rules Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Fixed JSDoc eslint errors Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> * Update the check-linters workflow to Node.js 20 --------- Signed-off-by: Matthew Nickson <mnickson@sidingsmedia.com> Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
45 lines
1.2 KiB
JavaScript
45 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) {
|
|
let 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 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;
|