Merge branch 'louislam:master' into logging

This commit is contained in:
Andreas Brett
2021-12-07 18:21:56 +01:00
committed by GitHub
12 changed files with 260 additions and 368 deletions

View File

@@ -0,0 +1,41 @@
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";
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;

View File

@@ -25,6 +25,7 @@ const DingDing = require("./notification-providers/dingding");
const Bark = require("./notification-providers/bark");
const { log_info } = require("../src/util");
const SerwerSMS = require("./notification-providers/serwersms");
const Stackfield = require("./notification-providers/stackfield");
class Notification {
@@ -61,6 +62,7 @@ class Notification {
new Webhook(),
new Bark(),
new SerwerSMS(),
new Stackfield(),
];
for (let item of list) {