diff --git a/server/notification-providers/gtx-messaging.js b/server/notification-providers/gtx-messaging.js new file mode 100644 index 0000000000..dca5522755 --- /dev/null +++ b/server/notification-providers/gtx-messaging.js @@ -0,0 +1,38 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class GtxMessaging extends NotificationProvider { + name = "gtxmessaging"; + + /** + * @inheritDoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + let authKey = notification.gtxMessagingApiKey; + let from = notification.gtxMessagingFrom.trim(); + let to = notification.gtxMessagingTo.trim(); + let text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", ""); + + try { + + let data = new URLSearchParams(); + data.append("from", from); + data.append("to", to); + data.append("text", text); + + let url = `https://rest.gtx-messaging.net/smsc/sendsms/${authKey}/json`; + + console.log(`will post url: ${url}, data:`, data); + + await axios.post(url, data); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = GtxMessaging; diff --git a/server/notification.js b/server/notification.js index 5e76d6eb1b..8beaf5bc9e 100644 --- a/server/notification.js +++ b/server/notification.js @@ -54,6 +54,7 @@ const GoAlert = require("./notification-providers/goalert"); const SMSManager = require("./notification-providers/smsmanager"); const ServerChan = require("./notification-providers/serverchan"); const ZohoCliq = require("./notification-providers/zoho-cliq"); +const GtxMessaging = require("./notification-providers/gtx-messaging"); class Notification { @@ -124,7 +125,8 @@ class Notification { new Webhook(), new WeCom(), new GoAlert(), - new ZohoCliq() + new ZohoCliq(), + new GtxMessaging(), ]; for (let item of list) { if (! item.name) { diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 57a2fdf2db..5f941544e3 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -151,7 +151,8 @@ export default { "Splunk": "Splunk", "webhook": "Webhook", "GoAlert": "GoAlert", - "ZohoCliq": "ZohoCliq" + "ZohoCliq": "ZohoCliq", + "gtxmessaging": "GtxMessaging" }; // Put notifications here if it's not supported in most regions or its documentation is not in English diff --git a/src/components/notifications/GtxMessaging.vue b/src/components/notifications/GtxMessaging.vue new file mode 100644 index 0000000000..b765ae90c2 --- /dev/null +++ b/src/components/notifications/GtxMessaging.vue @@ -0,0 +1,29 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 0606d41af6..0a7522039a 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -13,6 +13,7 @@ import GoogleChat from "./GoogleChat.vue"; import Gorush from "./Gorush.vue"; import Gotify from "./Gotify.vue"; import GrafanaOncall from "./GrafanaOncall.vue"; +import GtxMessaging from "./GtxMessaging.vue"; import HomeAssistant from "./HomeAssistant.vue"; import Kook from "./Kook.vue"; import Line from "./Line.vue"; @@ -111,7 +112,8 @@ const NotificationFormList = { "WeCom": WeCom, "GoAlert": GoAlert, "ServerChan": ServerChan, - "ZohoCliq": ZohoCliq + "ZohoCliq": ZohoCliq, + "gtxmessaging": GtxMessaging, }; export default NotificationFormList; diff --git a/src/lang/en.json b/src/lang/en.json index 0f59e62aef..eb15cb5309 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -883,5 +883,8 @@ "deleteRemoteBrowserMessage": "Are you sure want to delete this Remote Browser for all monitors?", "GrafanaOncallUrl": "Grafana Oncall URL", "Browser Screenshot": "Browser Screenshot", - "What is a Remote Browser?": "What is a Remote Browser?" + "What is a Remote Browser?": "What is a Remote Browser?", + "gtxMessagingApiKey": "API Key", + "gtxMessagingFrom": "From", + "gtxMessagingTo": "To" }