uptime-kuma/server/notification-providers/stackfield.js
Cassandra b287a25de7
Some checks failed
Auto Test / check-linters (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
json-yaml-validate / json-yaml-validate (push) Has been cancelled
Auto Test / auto-test (18, ARM64) (push) Has been cancelled
Auto Test / auto-test (18, macos-latest) (push) Has been cancelled
Auto Test / auto-test (18, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (18, windows-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, ARM64) (push) Has been cancelled
Auto Test / auto-test (20.5, macos-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, ubuntu-latest) (push) Has been cancelled
Auto Test / auto-test (20.5, windows-latest) (push) Has been cancelled
Auto Test / armv7-simple-test (18, ARMv7) (push) Has been cancelled
Auto Test / armv7-simple-test (20, ARMv7) (push) Has been cancelled
Auto Test / e2e-test (push) Has been cancelled
feat: structured logging (JSON) (#5118)
2024-09-24 17:51:21 +08:00

45 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;