remove smpp (#595)

This commit is contained in:
Sam Machin
2026-07-28 10:32:18 -04:00
committed by GitHub
parent c0243583f1
commit 0b5c4d6537
6 changed files with 6 additions and 260 deletions
+1 -13
View File
@@ -11,7 +11,6 @@ import type {
RimelabsOptions,
SelectorOptions,
SipGateway,
SmppGateway,
WebHook,
WebhookOption,
} from "./types";
@@ -133,7 +132,7 @@ export const DEFAULT_WEBHOOK: WebHook = {
password: "",
};
/** Default SIP/SMPP Gateways */
/** Default SIP Gateways */
export const DEFAULT_SIP_INBOUND_GATEWAY: SipGateway = {
voip_carrier_sid: "",
ipv4: "",
@@ -144,16 +143,6 @@ export const DEFAULT_SIP_INBOUND_GATEWAY: SipGateway = {
outbound: 0,
};
export const DEFAULT_SMPP_GATEWAY: SmppGateway = {
voip_carrier_sid: "",
ipv4: "",
port: 2775,
is_primary: false,
use_tls: false,
netmask: 32,
inbound: 1,
outbound: 1,
};
/** Netmask Bits */
export const NETMASK_BITS = Array(32)
.fill(0)
@@ -468,7 +457,6 @@ export const API_PHONE_NUMBERS = `${API_BASE_URL}/PhoneNumbers`;
export const API_MS_TEAMS_TENANTS = `${API_BASE_URL}/MicrosoftTeamsTenants`;
export const API_SERVICE_PROVIDERS = `${API_BASE_URL}/ServiceProviders`;
export const API_CARRIERS = `${API_BASE_URL}/VoipCarriers`;
export const API_SMPP_GATEWAY = `${API_BASE_URL}/SmppGateways`;
export const API_SIP_GATEWAY = `${API_BASE_URL}/SipGateways`;
export const API_PASSWORD_SETTINGS = `${API_BASE_URL}/PasswordSettings`;
export const API_FORGOT_PASSWORD = `${API_BASE_URL}/forgot-password`;
-20
View File
@@ -14,7 +14,6 @@ import {
API_MS_TEAMS_TENANTS,
API_PHONE_NUMBERS,
API_CARRIERS,
API_SMPP_GATEWAY,
API_SIP_GATEWAY,
API_PASSWORD_SETTINGS,
API_FORGOT_PASSWORD,
@@ -67,7 +66,6 @@ import type {
MSTeamsTenant,
PhoneNumber,
Carrier,
SmppGateway,
SipGateway,
TotalResponse,
CallQuery,
@@ -394,13 +392,6 @@ export const postSipGateway = (payload: Partial<SipGateway>) => {
return postFetch<SidResponse, Partial<SipGateway>>(API_SIP_GATEWAY, payload);
};
export const postSmppGateway = (payload: Partial<SmppGateway>) => {
return postFetch<SidResponse, Partial<SmppGateway>>(
API_SMPP_GATEWAY,
payload,
);
};
export const postServiceProviderLimit = (
sid: string,
payload: Partial<Limit>,
@@ -601,13 +592,6 @@ export const putSipGateway = (sid: string, payload: Partial<SipGateway>) => {
);
};
export const putSmppGateway = (sid: string, payload: Partial<SmppGateway>) => {
return putFetch<EmptyResponse, Partial<SmppGateway>>(
`${API_SMPP_GATEWAY}/${sid}`,
payload,
);
};
export const putLcr = (sid: string, payload: Partial<Lcr>) => {
return putFetch<EmptyResponse, Partial<Lcr>>(`${API_LCRS}/${sid}`, payload);
};
@@ -713,10 +697,6 @@ export const deleteSipGateway = (sid: string) => {
return deleteFetch<EmptyResponse>(`${API_SIP_GATEWAY}/${sid}`);
};
export const deleteSmppGateway = (sid: string) => {
return deleteFetch<EmptyResponse>(`${API_SMPP_GATEWAY}/${sid}`);
};
export const deleteServiceProviderLimit = (
sid: string,
cat: LimitCategories,
+1 -22
View File
@@ -52,7 +52,7 @@ export enum StatusCodes {
NOT_FOUND = 404,
UNPROCESSABLE_ENTITY = 422,
INTERNAL_SERVER_ERROR = 500,
/** SMPP temporarily unavailable */
/** temporarily unavailable */
TEMPORARILY_UNAVAILABLE = 480,
}
@@ -246,15 +246,6 @@ export interface Sbc {
service_provider_sid: null | string;
}
export interface Smpp {
ipv4: string;
port: number | string;
use_tls: boolean;
is_primary: boolean;
smpp_address_sid: string;
service_provider_sid: null | string;
}
export interface Account {
name: string;
sip_realm: null | string;
@@ -492,11 +483,6 @@ export interface Carrier {
diversion: null | string;
inbound_auth_username: string;
inbound_auth_password: string;
smpp_system_id: null | string;
smpp_password: null | string;
smpp_inbound_system_id: null | string;
smpp_inbound_password: null | string;
smpp_enquire_link_interval: number;
register_status: CarrierRegisterStatus;
dtmf_type: DtmfType;
outbound_sip_proxy: string | null;
@@ -528,13 +514,6 @@ export interface SipGateway extends Gateway {
dtls_off?: boolean;
}
export interface SmppGateway extends Gateway {
smpp_gateway_sid?: null | string;
is_primary: boolean;
use_tls: boolean;
port: number;
}
export interface Lcr {
lcr_sid?: null | string;
is_active: boolean;
@@ -6,7 +6,7 @@ import { useApiData } from "src/api";
import { useSelectState } from "src/store";
import { CarrierForm } from "./form";
import { Carrier, SipGateway, SmppGateway } from "src/api/types";
import { Carrier, SipGateway } from "src/api/types";
import { useScopedRedirect } from "src/utils/use-scoped-redirect";
import { ROUTE_INTERNAL_CARRIERS } from "src/router/routes";
import { Scope } from "src/store/types";
@@ -22,9 +22,6 @@ export const EditCarrier = () => {
const [sipGateways, sipGatewaysRefetch] = useApiData<SipGateway[]>(
`SipGateways?voip_carrier_sid=${params.voip_carrier_sid}`,
);
const [smppGateways, smppGatewaysRefetch] = useApiData<SmppGateway[]>(
`SmppGateways?voip_carrier_sid=${params.voip_carrier_sid}`,
);
useScopedRedirect(
Scope.account,
@@ -49,10 +46,6 @@ export const EditCarrier = () => {
data: sipGateways,
refetch: sipGatewaysRefetch,
}}
carrierSmppGateways={{
data: smppGateways,
refetch: smppGatewaysRefetch,
}}
/>
</>
);
@@ -6,10 +6,8 @@ import {
deleteSipGateway,
postCarrier,
postSipGateway,
postSmppGateway,
putCarrier,
putSipGateway,
putSmppGateway,
useApiData,
useServiceProviderData,
postPredefinedCarrierTemplate,
@@ -17,10 +15,8 @@ import {
} from "src/api";
import {
DEFAULT_SIP_INBOUND_GATEWAY,
DEFAULT_SMPP_GATEWAY,
DTMF_TYPE_SELECTION,
FQDN,
FQDN_TOP_LEVEL,
INVALID,
IP,
NETMASK_OPTIONS,
@@ -58,7 +54,6 @@ import {
type UseApiDataMap,
type Carrier,
type SipGateway,
type SmppGateway,
type PredefinedCarrier,
type Sbc,
type Application,
@@ -72,13 +67,11 @@ import { useToast } from "src/components/toast/toast-provider";
type CarrierFormProps = {
carrier?: UseApiDataMap<Carrier>;
carrierSipGateways?: UseApiDataMap<SipGateway[]>;
carrierSmppGateways?: UseApiDataMap<SmppGateway[]>;
};
export const CarrierForm = ({
carrier,
carrierSipGateways,
carrierSmppGateways,
}: CarrierFormProps) => {
const { toastSuccess, toastError } = useToast();
const navigate = useNavigate();
@@ -88,7 +81,6 @@ export const CarrierForm = ({
const refSipInboundIp = useRef<HTMLInputElement[]>([]);
const refSipOutboundIp = useRef<HTMLInputElement[]>([]);
const refSipPort = useRef<HTMLInputElement[]>([]);
const refSmppIp = useRef<HTMLInputElement[]>([]);
const refInboundAuthUsername = useRef<HTMLInputElement>(null);
const [sbcs] = useApiData<Sbc[]>("Sbcs");
const [applications] = useServiceProviderData<Application[]>("Applications");
@@ -128,11 +120,6 @@ export const CarrierForm = ({
const [initialRegister, setInitialRegister] = useState(false);
const [initialSipRegister, setInitialSipRegister] = useState(false);
const [smppSystemId, setSmppSystemId] = useState("");
const [smppPass, setSmppPass] = useState("");
const [smppInboundSystemId, setSmppInboundSystemId] = useState("");
const [smppInboundPass, setSmppInboundPass] = useState("");
const [sipInboundGateways, setSipInboundGateways] = useState<SipGateway[]>(
[],
);
@@ -145,16 +132,6 @@ export const CarrierForm = ({
const [tmpOutboundGateways, setTmpOutboundGateways] = useState<SipGateway[]>(
[],
);
const [smppGateways, setSmppGateways] = useState<SmppGateway[]>([
{
...DEFAULT_SMPP_GATEWAY,
inbound: 0,
},
{
...DEFAULT_SMPP_GATEWAY,
outbound: 0,
},
]);
const [sipInboundMessage, setSipInboundMessage] = useState("");
const [sipOutboundMessage, setSipOutboundMessage] = useState("");
@@ -305,18 +282,6 @@ export const CarrierForm = ({
setInitialSipRegister(false);
}
if (obj.smpp_system_id) {
setSmppSystemId(obj.smpp_system_id);
}
if (obj.smpp_password) {
setSmppPass(obj.smpp_password);
}
if (obj.smpp_inbound_system_id) {
setSmppInboundSystemId(obj.smpp_inbound_system_id);
}
if (obj.smpp_inbound_password) {
setSmppInboundPass(obj.smpp_inbound_password);
}
if (obj.dtmf_type) {
setDtmfType(obj.dtmf_type);
}
@@ -346,16 +311,6 @@ export const CarrierForm = ({
]);
};
const addSmppGateway = (obj: Partial<SmppGateway>) => {
setSmppGateways((curr) => [
...curr,
{
...DEFAULT_SMPP_GATEWAY /** { inbound: 1, outbound: 1 } */,
...obj /** pass the values: e.g. { outbound: 1, inbound: 0 } */,
},
]);
};
const updateSipInboundGateways = (
index: number,
key: string,
@@ -427,23 +382,6 @@ export const CarrierForm = ({
});
};
const handleSmppGatewayPutPost = (voip_carrier_sid: string) => {
Promise.all(
smppGateways
/** Ensure the empty UI fields don't actually save in the background... */
.filter((g) => g.ipv4.trim() !== "" && isValidPort(g.port))
.map(({ smpp_gateway_sid, ...g }: SmppGateway) => {
smpp_gateway_sid
? putSmppGateway(smpp_gateway_sid, g)
: postSmppGateway({ ...g, voip_carrier_sid });
}),
).then(() => {
if (carrierSmppGateways) {
carrierSmppGateways.refetch();
}
});
};
const handleSipGatewayDelete = (g?: SipGateway) => {
if (g && g.sip_gateway_sid) {
deleteSipGateway(g.sip_gateway_sid).then(() =>
@@ -452,16 +390,6 @@ export const CarrierForm = ({
}
};
const hasEmptySmppGateways = (type: keyof SmppGateway) => {
const filtered = smppGateways.filter((g) => g[type]);
return (
hasLength(filtered) &&
filtered.reduce((acc, g) => {
return acc + g.ipv4.trim();
}, "") === ""
);
};
const getSipValidation = () => {
if (
trunkType === "static_ip" &&
@@ -573,63 +501,6 @@ export const CarrierForm = ({
}
};
const getSmppValidation = () => {
for (let i = 0; i < smppGateways.length; i++) {
const gateway = smppGateways[i];
const gatewayType = gateway.inbound ? "inbound" : "outbound";
const type = getIpValidationType(gateway.ipv4);
if (type === FQDN_TOP_LEVEL) {
refSmppIp.current[i].focus();
return {
msg: "When using an FQDN, you must use a subdomain (e.g. sip.example.com).",
type: gatewayType,
};
} else if (type === FQDN && (!gateway.outbound || gateway.inbound)) {
refSmppIp.current[i].focus();
return {
msg: "A fully qualified domain name may only be used for outbound calls.",
type: gatewayType,
};
} else if (type === INVALID && gateway.ipv4.trim() !== "") {
refSmppIp.current[i].focus();
return {
msg: `Please provide a valid ${gatewayType} IP address or fully qualified domain name.`,
type: gatewayType,
};
}
/** Duplicates validation */
const dupeSmppGateway = smppGateways.find((g) => {
return (
g !== gateway &&
gateway.ipv4 &&
g[gatewayType] === gateway[gatewayType] &&
g.ipv4 === gateway.ipv4 &&
g.port === gateway.port
);
});
if (dupeSmppGateway) {
refSmppIp.current[i].focus();
return {
msg: `Each ${gatewayType} SMPP gateway must have a unique IP address.`,
type: gatewayType,
};
}
}
};
const shouldValidateSmpp = () => {
return (
smppSystemId ||
smppPass ||
smppInboundPass ||
!hasEmptySmppGateways("outbound") ||
!hasEmptySmppGateways("inbound")
);
};
const handleActiveTab = () => {
const gatewaysToCheck =
trunkType === "auth"
@@ -658,25 +529,6 @@ export const CarrierForm = ({
setActiveTab("sip");
return; /** Important so browser contstraints work properly */
}
/** When to switch to the `smpp` tab */
const invalidSmppPort = smppGateways
.filter((g) => g.outbound)
.find((g) => !isValidPort(g.port));
const smppGatewayValidation = shouldValidateSmpp() && getSmppValidation();
/** Outbound user/pass filled out but no gateways */
/** Inbound gateways but no inbound pass */
/** Invalid SMPP port number */
if (
invalidSmppPort ||
smppGatewayValidation ||
(smppSystemId && smppPass && hasEmptySmppGateways("outbound")) ||
(!smppInboundPass && !hasEmptySmppGateways("inbound"))
) {
setActiveTab("smpp");
}
};
const handleSubmit = (e: React.FormEvent) => {
@@ -743,10 +595,6 @@ export const CarrierForm = ({
tech_prefix: prefix.trim() || null,
diversion: diversion.trim() || null,
is_active: isActive,
smpp_system_id: smppSystemId.trim() || null,
smpp_password: smppPass.trim() || null,
smpp_inbound_system_id: smppInboundSystemId.trim() || null,
smpp_inbound_password: smppInboundPass.trim() || null,
dtmf_type: dtmfType,
trunk_type: trunkType,
inbound_auth_username: inboundAuthUsername.trim() || undefined,
@@ -763,7 +611,6 @@ export const CarrierForm = ({
.then(() => {
if (carrier.data?.voip_carrier_sid) {
handleSipGatewayPutPost(carrier.data.voip_carrier_sid);
handleSmppGatewayPutPost(carrier.data.voip_carrier_sid);
}
toastSuccess("Carrier updated successfully");
@@ -782,7 +629,6 @@ export const CarrierForm = ({
})
.then(({ json }) => {
handleSipGatewayPutPost(json.sid);
handleSmppGatewayPutPost(json.sid);
toastSuccess("Carrier created successfully");
navigate(ROUTE_INTERNAL_CARRIERS);
@@ -834,7 +680,6 @@ export const CarrierForm = ({
/** This fixes a re-rendering glitch when we used useEffect that was annoying but not breaking */
/** https://beta.reactjs.org/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes */
const [prevSipGateways, setPrevSipGateways] = useState<SipGateway[]>();
const [prevSmppGateways, setPrevSmppGateways] = useState<SmppGateway[]>();
if (
carrierSipGateways &&
@@ -858,26 +703,6 @@ export const CarrierForm = ({
}
}
if (
carrierSmppGateways &&
hasLength(carrierSmppGateways.data) &&
carrierSmppGateways.data !== prevSmppGateways
) {
const inbound = carrierSmppGateways.data.filter((g) => g.inbound);
const outbound = carrierSmppGateways.data.filter((g) => g.outbound);
setPrevSmppGateways(carrierSmppGateways.data); /** Deadly important */
setSmppGateways(carrierSmppGateways.data);
if (inbound.length <= 0) {
addSmppGateway({ inbound: 1, outbound: 0 });
}
if (outbound.length <= 0) {
addSmppGateway({ outbound: 1, inbound: 0 });
}
}
const handleInvalidField = (e: React.InvalidEvent<HTMLFormElement>) => {
const invalidField = e.target as unknown as HTMLInputElement;
const fieldName = invalidField.name || invalidField.id;
@@ -889,8 +714,6 @@ export const CarrierForm = ({
targetTab = "inbound";
} else if (fieldName?.includes("sip_") || fieldName?.includes("from_")) {
targetTab = "outbound";
} else if (fieldName?.includes("smpp_")) {
targetTab = "smpp";
}
// If we're not on the right tab, switch to it
@@ -4,7 +4,6 @@ import { Button, ButtonGroup, H1, Icon, M, MS } from "@jambonz/ui-kit";
import {
deleteCarrier,
deleteSipGateway,
deleteSmppGateway,
getFetch,
getSPVoipCarriers,
useApiData,
@@ -26,7 +25,6 @@ import { Gateways } from "./gateways";
import { isUserAccountScope, hasLength, hasValue } from "src/utils";
import {
API_SIP_GATEWAY,
API_SMPP_GATEWAY,
CARRIER_REG_OK,
ENABLE_HOSTED_SYSTEM,
PER_PAGE_SELECTION,
@@ -42,7 +40,6 @@ import type {
Carrier,
CurrentUserData,
SipGateway,
SmppGateway,
} from "src/api/types";
import { Scope } from "src/store/types";
import { getAccountFilter, setLocation } from "src/store/localStore";
@@ -112,14 +109,9 @@ export const Carriers = () => {
deleteCarrier(carrier.voip_carrier_sid)
.then(() => {
Promise.all([
getFetch<SipGateway[]>(
`${API_SIP_GATEWAY}?voip_carrier_sid=${carrier.voip_carrier_sid}`,
),
getFetch<SmppGateway[]>(
`${API_SMPP_GATEWAY}?voip_carrier_sid=${carrier.voip_carrier_sid}`,
),
]).then(([sipGatewaysRes, smppGatewaysRes]) => {
).then((sipGatewaysRes) => {
hasLength(sipGatewaysRes.json) &&
sipGatewaysRes.json.forEach(
(g) =>
@@ -129,15 +121,6 @@ export const Carriers = () => {
toastError(error.msg),
),
);
hasLength(smppGatewaysRes.json) &&
smppGatewaysRes.json.forEach(
(g) =>
g &&
g.smpp_gateway_sid &&
deleteSmppGateway(g.smpp_gateway_sid).catch((error) =>
toastError(error.msg),
),
);
});
setCarrier(null);
fetchCarriers(false);