-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gtxmessaging Notification Support (#4481)
Signed-off-by: Christoph Fichtmüller <[email protected]> Co-authored-by: Frank Elsinga <[email protected]>
- Loading branch information
1 parent
e927327
commit 49b6dac
Showing
6 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters