diff --git a/server/notification-providers/flowtriq.js b/server/notification-providers/flowtriq.js new file mode 100644 index 000000000..dcd27a997 --- /dev/null +++ b/server/notification-providers/flowtriq.js @@ -0,0 +1,79 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); +const { DOWN, UP } = require("../../src/util"); + +class Flowtriq extends NotificationProvider { + name = "Flowtriq"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let status = "info"; + let monitorName = monitorJSON?.name || "Unknown"; + + if (heartbeatJSON != null) { + if (heartbeatJSON.status === DOWN) { + status = "down"; + } else if (heartbeatJSON.status === UP) { + status = "up"; + } + } + + let data = { + source: "uptime-kuma", + status: status, + monitor: monitorName, + msg: msg, + }; + + if (heartbeatJSON) { + data.heartbeat = { + status: heartbeatJSON.status, + time: heartbeatJSON.time, + ping: heartbeatJSON.ping, + msg: heartbeatJSON.msg, + timezone: heartbeatJSON.timezone, + }; + } + + if (monitorJSON) { + data.monitorInfo = { + id: monitorJSON.id, + name: monitorJSON.name, + type: monitorJSON.type, + url: monitorJSON.url, + hostname: monitorJSON.hostname, + port: monitorJSON.port, + }; + } + + let headers = { + "Content-Type": "application/json", + }; + + if (notification.flowtriqApiKey) { + headers["X-API-Key"] = notification.flowtriqApiKey; + } + + let config = this.getAxiosConfigWithProxy({ + headers: headers, + }); + + let result = await axios.post(notification.flowtriqWebhookUrl, data, config); + + if (result.status < 200 || result.status >= 300) { + throw new Error("Flowtriq notification failed with status code " + result.status); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Flowtriq; diff --git a/server/notification.js b/server/notification.js index c1a97d5aa..8e2f4d754 100644 --- a/server/notification.js +++ b/server/notification.js @@ -42,6 +42,7 @@ const JiraServiceManagement = require("./notification-providers/jira-service-man const PagerDuty = require("./notification-providers/pagerduty"); const Pumble = require("./notification-providers/pumble"); const FlashDuty = require("./notification-providers/flashduty"); +const Flowtriq = require("./notification-providers/flowtriq"); const PagerTree = require("./notification-providers/pagertree"); const PromoSMS = require("./notification-providers/promosms"); const Pushbullet = require("./notification-providers/pushbullet"); @@ -152,6 +153,7 @@ class Notification { new JiraServiceManagement(), new PagerDuty(), new FlashDuty(), + new Flowtriq(), new PagerTree(), new PromoSMS(), new Pumble(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index cbf56d387..4a34c5e1f 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -292,6 +292,7 @@ export default { let incidentManagement = { alerta: "Alerta", AlertNow: "AlertNow", + Flowtriq: "Flowtriq", GoAlert: "GoAlert", GrafanaOncall: "Grafana Oncall", HeiiOnCall: "Heii On-Call", diff --git a/src/components/notifications/Flowtriq.vue b/src/components/notifications/Flowtriq.vue new file mode 100644 index 000000000..9fd1bf620 --- /dev/null +++ b/src/components/notifications/Flowtriq.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 275be717c..44e3c2036 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -41,6 +41,7 @@ import Opsgenie from "./Opsgenie.vue"; import JiraServiceManagement from "./JiraServiceManagement.vue"; import PagerDuty from "./PagerDuty.vue"; import FlashDuty from "./FlashDuty.vue"; +import Flowtriq from "./Flowtriq.vue"; import PagerTree from "./PagerTree.vue"; import PromoSMS from "./PromoSMS.vue"; import Pumble from "./Pumble.vue"; @@ -140,6 +141,7 @@ const NotificationFormList = { JiraServiceManagement: JiraServiceManagement, PagerDuty: PagerDuty, FlashDuty: FlashDuty, + Flowtriq: Flowtriq, PagerTree: PagerTree, promosms: PromoSMS, pumble: Pumble, diff --git a/src/lang/en.json b/src/lang/en.json index d05a8d1d8..4595c9d02 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1103,6 +1103,9 @@ "FlashDuty Severity": "Severity", "FlashDuty Push URL": "Push URL", "FlashDuty Push URL Placeholder": "Copy from the alerting integration page", + "Flowtriq Webhook URL": "Webhook URL", + "Flowtriq API Key": "API Key", + "flowtriqApiKeyDescription": "Optional API key for authenticating webhook requests to your Flowtriq instance.", "nostrRelays": "Nostr relays", "nostrRelaysHelp": "One relay URL per line", "nostrSender": "Sender Private Key (nsec)",