Skip to content

Commit

Permalink
Add gtx messaging Notification Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
cfichtmueller committed Feb 15, 2024
1 parent 0e7ef54 commit ac109d0
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
38 changes: 38 additions & 0 deletions server/notification-providers/gtx-messaging.js
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 3 additions & 1 deletion server/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/NotificationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions src/components/notifications/GtxMessaging.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div class="mb-3">
<label for="gtxmessaging-api-key" class="form-label">{{ $t("gtxMessagingApiKey") }}</label>
<HiddenInput id="gtxmessaging-api-key" v-model="$parent.notification.gtxMessagingApiKey" :required="true"></HiddenInput>
</div>
<div class="mb-3">
<label for="gtxmessaging-from" class="form-label">{{ $t("gtxMessagingFrom") }}</label>
<input id="gtxmessaging-from" v-model="$parent.notification.gtxMessagingFrom" type="text" class="form-control" required>
</div>
<div class="mb-3">
<label for="gtxmessaging-to" class="form-label">{{ $t("gtxMessagingTo") }}</label>
<input id="gtxmessaging-to" v-model="$parent.notification.gtxMessagingTo" type="text" pattern="^[\d-]{10,31}(@[\w\.]{1,})?$" class="form-control" required>
</div>
<div class="mb-3">
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px;">
<a href="https://www.gtx-messaging.com/en/solutions/sms-gateway-api/" target="_blank">https://www.gtx-messaging.com/en/solutions/sms-gateway-api/</a>
</i18n-t>
</div>
</template>

<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput
}
};
</script>
4 changes: 3 additions & 1 deletion src/components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -111,7 +112,8 @@ const NotificationFormList = {
"WeCom": WeCom,
"GoAlert": GoAlert,
"ServerChan": ServerChan,
"ZohoCliq": ZohoCliq
"ZohoCliq": ZohoCliq,
"gtxmessaging": GtxMessaging,
};

export default NotificationFormList;
5 changes: 4 additions & 1 deletion src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit ac109d0

Please sign in to comment.