uptime-kuma/server/notification-providers/stackfield.js
Cassandra Beelen e85789ecae
chore: addressing of simple deprecations surrounding Settings and log
Co-authored-by: Frank Elsinga <frank@elsinga.de>
Closes: #4391

Squashed commit of the following:

commit 828d2a73d4
Merge: 10f771cf dd758903
Author: Frank Elsinga <frank@elsinga.de>
Date:   Fri Sep 13 22:51:25 2024 +0800

    Merge branch 'master' into deprecations

commit 10f771cfc6
Author: Frank Elsinga <frank@elsinga.de>
Date:   Thu Jan 18 22:36:12 2024 +0100

    formatting fixes

commit d737b19e2f
Author: Frank Elsinga <frank@elsinga.de>
Date:   Thu Jan 18 21:27:30 2024 +0100

    migrated all settings to use the `Settings` class

commit c5e26e993e
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
2024-10-10 16:48:10 +02:00

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;