mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-21 11:05:56 +00:00
Co-authored-by: Frank Elsinga <frank@elsinga.de> Closes: #4391 Squashed commit of the following: commit828d2a73d4
Merge:10f771cf
dd758903
Author: Frank Elsinga <frank@elsinga.de> Date: Fri Sep 13 22:51:25 2024 +0800 Merge branch 'master' into deprecations commit10f771cfc6
Author: Frank Elsinga <frank@elsinga.de> Date: Thu Jan 18 22:36:12 2024 +0100 formatting fixes commitd737b19e2f
Author: Frank Elsinga <frank@elsinga.de> Date: Thu Jan 18 21:27:30 2024 +0100 migrated all settings to use the `Settings` class commitc5e26e993e
Author: Frank Elsinga <frank@elsinga.de> Date: Thu Jan 18 21:04:44 2024 +0100 removed the deprecated logging functionality * fix(server/model/monitor): duplicate `Settings.set` for `tlsExpiryNotifyDays` * fix(eslint): minor linter complaints & a typo
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
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;
|