feat: add SMS Gateway notification provider (#7720)

This commit is contained in:
Matt Shields authored and GitHub committed 2026-08-21 18:54:22 +08:00
1 parent 7598afbef8
commit a808c63fe9
6 files changed
+114 -1

No files matched your search

@@ -0,0 +1,55 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class SMSGateway extends NotificationProvider {
name = "SMSGateway";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
const url = notification.smsgatewayUrl.replace(/\/+$/, "") + "/api/v1/sms/send";
const recipients = notification.smsgatewayTo
.split(",")
.map((number) => number.trim())
.filter((number) => number !== "");
try {
const config = this.getAxiosConfigWithProxy({
headers: {
"X-API-Key": notification.smsgatewayApiKey,
},
});
const failures = [];
for (const to of recipients) {
const result = await axios.post(
url,
{
to,
body: msg,
},
config
);
// The gateway responds with HTTP 200 even if the modem could
// not send the message, so the body status must be checked.
if (result.data.status === "failed") {
failures.push(`${to}: ${result.data.message || "unknown error"}`);
}
}
if (failures.length > 0) {
throw new Error("Failed to send SMS to " + failures.join("; "));
}
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = SMSGateway;
+2
View File
@@ -62,6 +62,7 @@ const SIGNL4 = require("./notification-providers/signl4");
const Slack = require("./notification-providers/slack");
const SMSPartner = require("./notification-providers/smspartner");
const SMSEagle = require("./notification-providers/smseagle");
const SMSGateway = require("./notification-providers/sms-gateway");
const SMTP = require("./notification-providers/smtp");
const Squadcast = require("./notification-providers/squadcast");
const Stackfield = require("./notification-providers/stackfield");
@@ -185,6 +186,7 @@ class Notification {
new SMSPartner(),
new Slack(),
new SMSEagle(),
new SMSGateway(),
new SMTP(),
new Squadcast(),
new Stackfield(),
+1
View File
@@ -279,6 +279,7 @@ export default {
plivo: "Plivo",
SevenIO: "SevenIO",
SMSEagle: "SMSEagle",
SMSGateway: "SMS Gateway",
SMSPartner: "SMS Partner",
telnyx: "Telnyx",
Teltonika: this.$t("Teltonika SMS Gateway"),
@@ -0,0 +1,50 @@
<template>
<div class="mb-3">
<label for="smsgateway-url" class="form-label">{{ $t("Server URL") }}</label>
<input
id="smsgateway-url"
v-model="$parent.notification.smsgatewayUrl"
type="url"
class="form-control"
placeholder="http://localhost:8080"
required
/>
<div class="form-text">{{ $t("smsgatewayUrlHelptext") }}</div>
</div>
<div class="mb-3">
<label for="smsgateway-api-key" class="form-label">{{ $t("API Key") }}</label>
<HiddenInput
id="smsgateway-api-key"
v-model="$parent.notification.smsgatewayApiKey"
:required="true"
autocomplete="new-password"
></HiddenInput>
</div>
<div class="mb-3">
<label for="smsgateway-to" class="form-label">{{ $t("smsgatewayTo") }}</label>
<input
id="smsgateway-to"
v-model="$parent.notification.smsgatewayTo"
type="text"
class="form-control"
placeholder="+15551234567, +15559876543"
required
/>
<div class="form-text">{{ $t("smsgatewayToHelptext") }}</div>
</div>
<i18n-t tag="div" keypath="Read more:" class="form-text">
<a href="https://github.com/mattboston/sms-gateway" target="_blank">
https://github.com/mattboston/sms-gateway
</a>
</i18n-t>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
export default {
components: {
HiddenInput,
},
};
</script>
+2
View File
@@ -59,6 +59,7 @@ import RocketChat from "./RocketChat.vue";
import ServerChan from "./ServerChan.vue";
import SerwerSMS from "./SerwerSMS.vue";
import Signal from "./Signal.vue";
import SMSGateway from "./SMSGateway.vue";
import SMSManager from "./SMSManager.vue";
import SMSPartner from "./SMSPartner.vue";
import Slack from "./Slack.vue";
@@ -169,6 +170,7 @@ const NotificationFormList = {
serwersms: SerwerSMS,
signal: Signal,
SIGNL4: SIGNL4,
SMSGateway: SMSGateway,
SMSManager: SMSManager,
SMSPartner: SMSPartner,
slack: Slack,
+4 -1
View File
@@ -1606,5 +1606,8 @@
"milkyGroupMessage": "Group",
"milkyPrivateMessage": "Private",
"milkyUserOrGroupId": "Group/User ID",
"milkySafetyTips": "For safety, must set access token"
"milkySafetyTips": "For safety, must set access token",
"smsgatewayUrlHelptext": "The base URL of your SMS Gateway, without an API path.",
"smsgatewayTo": "Phone Number(s)",
"smsgatewayToHelptext": "Comma-separated list of recipient phone numbers in international format (e.g. +15551234567)"
}