summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/stackfield.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/notification-providers/stackfield.js')
-rw-r--r--server/notification-providers/stackfield.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/server/notification-providers/stackfield.js b/server/notification-providers/stackfield.js
new file mode 100644
index 0000000..65a9245
--- /dev/null
+++ b/server/notification-providers/stackfield.js
@@ -0,0 +1,44 @@
+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.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;