Add gtxmessaging Notification Support (#4481)

Signed-off-by: Christoph Fichtmüller <cf@cfichtmueller.com>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
Christoph Fichtmüller 2024-03-26 23:59:09 +01:00 committed by GitHub
parent e927327bad
commit 49b6dacb4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 96 additions and 4 deletions

View File

@ -0,0 +1,33 @@
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.";
// The UP/DOWN symbols will be replaced with `???` by gtx-messaging
const text = msg.replaceAll("🔴 ", "").replaceAll("✅ ", "");
try {
const data = new URLSearchParams();
data.append("from", notification.gtxMessagingFrom.trim());
data.append("to", notification.gtxMessagingTo.trim());
data.append("text", text);
const url = `https://rest.gtx-messaging.net/smsc/sendsms/${notification.gtxMessagingApiKey}/json`;
await axios.post(url, data);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = GtxMessaging;

View File

@ -55,6 +55,7 @@ const GoAlert = require("./notification-providers/goalert");
const SMSManager = require("./notification-providers/smsmanager"); const SMSManager = require("./notification-providers/smsmanager");
const ServerChan = require("./notification-providers/serverchan"); const ServerChan = require("./notification-providers/serverchan");
const ZohoCliq = require("./notification-providers/zoho-cliq"); const ZohoCliq = require("./notification-providers/zoho-cliq");
const GtxMessaging = require("./notification-providers/gtx-messaging");
class Notification { class Notification {
@ -126,7 +127,8 @@ class Notification {
new Webhook(), new Webhook(),
new WeCom(), new WeCom(),
new GoAlert(), new GoAlert(),
new ZohoCliq() new ZohoCliq(),
new GtxMessaging(),
]; ];
for (let item of list) { for (let item of list) {
if (! item.name) { if (! item.name) {

View File

@ -152,7 +152,8 @@ export default {
"Splunk": "Splunk", "Splunk": "Splunk",
"webhook": "Webhook", "webhook": "Webhook",
"GoAlert": "GoAlert", "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 // Put notifications here if it's not supported in most regions or its documentation is not in English

View File

@ -0,0 +1,49 @@
<template>
<div class="mb-3">
<label for="gtxmessaging-api-key" class="form-label">{{ $t("API Key") }}</label>
<HiddenInput id="gtxmessaging-api-key" v-model="$parent.notification.gtxMessagingApiKey" :required="true"></HiddenInput>
<div class="form-text">
{{ $t("gtxMessagingApiKeyHint") }}
</div>
</div>
<div class="mb-3">
<label for="gtxmessaging-from" class="form-label">{{ $t("From Phone Number / Transmission Path Originating Address (TPOA)") }}</label>
<input id="gtxmessaging-from" v-model="$parent.notification.gtxMessagingFrom" type="text" class="form-control" required>
<i18n-t tag="div" keypath="gtxMessagingFromHint" class="form-text">
<template #e164>
<a href="https://wikipedia.org/wiki/E.164">E.164</a>
</template>
<template #e212>
<a href="https://wikipedia.org/wiki/E.212">E.212</a>
</template>
<template #e214>
<a href="https://wikipedia.org/wiki/E.214">E.214</a>
</template>
</i18n-t>
</div>
<div class="mb-3">
<label for="gtxmessaging-to" class="form-label">{{ $t("To Phone Number") }}</label>
<input id="gtxmessaging-to" v-model="$parent.notification.gtxMessagingTo" type="text" pattern="^\+\d+$" class="form-control" required>
<i18n-t tag="div" keypath="gtxMessagingToHint" class="form-text">
<template #e164>
<a href="https://wikipedia.org/wiki/E.164">E.164</a>
</template>
<template #e212>
<a href="https://wikipedia.org/wiki/E.212">E.212</a>
</template>
<template #e214>
<a href="https://wikipedia.org/wiki/E.214">E.214</a>
</template>
</i18n-t>
</div>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput
}
};
</script>

View File

@ -13,6 +13,7 @@ import GoogleChat from "./GoogleChat.vue";
import Gorush from "./Gorush.vue"; import Gorush from "./Gorush.vue";
import Gotify from "./Gotify.vue"; import Gotify from "./Gotify.vue";
import GrafanaOncall from "./GrafanaOncall.vue"; import GrafanaOncall from "./GrafanaOncall.vue";
import GtxMessaging from "./GtxMessaging.vue";
import HomeAssistant from "./HomeAssistant.vue"; import HomeAssistant from "./HomeAssistant.vue";
import HeiiOnCall from "./HeiiOnCall.vue"; import HeiiOnCall from "./HeiiOnCall.vue";
import Kook from "./Kook.vue"; import Kook from "./Kook.vue";
@ -113,7 +114,8 @@ const NotificationFormList = {
"WeCom": WeCom, "WeCom": WeCom,
"GoAlert": GoAlert, "GoAlert": GoAlert,
"ServerChan": ServerChan, "ServerChan": ServerChan,
"ZohoCliq": ZohoCliq "ZohoCliq": ZohoCliq,
"gtxmessaging": GtxMessaging,
}; };
export default NotificationFormList; export default NotificationFormList;

View File

@ -887,5 +887,10 @@
"Browser Screenshot": "Browser Screenshot", "Browser Screenshot": "Browser Screenshot",
"What is a Remote Browser?": "What is a Remote Browser?", "What is a Remote Browser?": "What is a Remote Browser?",
"wayToGetHeiiOnCallDetails": "How to get the Trigger ID and API Keys is explained in the {documentation}", "wayToGetHeiiOnCallDetails": "How to get the Trigger ID and API Keys is explained in the {documentation}",
"documentationOf": "{0} Documentation" "documentationOf": "{0} Documentation",
"gtxMessagingApiKeyHint": "You can find your API key at: My Routing Accounts > Show Account Information > API Credentials > REST API (v2.x)",
"From Phone Number / Transmission Path Originating Address (TPOA)": "From Phone Number / Transmission Path Originating Address (TPOA)",
"gtxMessagingFromHint": "On mobile phones, your recipients sees the TPOA displayed as the sender of the message. Allowed are up to 11 alphanumeric characters, a shortcode, the local longcode or international numbers ({e164}, {e212} or {e214})",
"To Phone Number": "To Phone Number",
"gtxMessagingToHint": "International format, with leading \"+\" ({e164}, {e212} or {e214})"
} }