mirror of
https://github.com/jambonz/jambonz-webapp.git
synced 2026-08-19 09:30:23 +00:00
remove smpp (#595)
This commit is contained in:
+1
-13
@@ -11,7 +11,6 @@ import type {
|
|||||||
RimelabsOptions,
|
RimelabsOptions,
|
||||||
SelectorOptions,
|
SelectorOptions,
|
||||||
SipGateway,
|
SipGateway,
|
||||||
SmppGateway,
|
|
||||||
WebHook,
|
WebHook,
|
||||||
WebhookOption,
|
WebhookOption,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
@@ -133,7 +132,7 @@ export const DEFAULT_WEBHOOK: WebHook = {
|
|||||||
password: "",
|
password: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default SIP/SMPP Gateways */
|
/** Default SIP Gateways */
|
||||||
export const DEFAULT_SIP_INBOUND_GATEWAY: SipGateway = {
|
export const DEFAULT_SIP_INBOUND_GATEWAY: SipGateway = {
|
||||||
voip_carrier_sid: "",
|
voip_carrier_sid: "",
|
||||||
ipv4: "",
|
ipv4: "",
|
||||||
@@ -144,16 +143,6 @@ export const DEFAULT_SIP_INBOUND_GATEWAY: SipGateway = {
|
|||||||
outbound: 0,
|
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 */
|
/** Netmask Bits */
|
||||||
export const NETMASK_BITS = Array(32)
|
export const NETMASK_BITS = Array(32)
|
||||||
.fill(0)
|
.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_MS_TEAMS_TENANTS = `${API_BASE_URL}/MicrosoftTeamsTenants`;
|
||||||
export const API_SERVICE_PROVIDERS = `${API_BASE_URL}/ServiceProviders`;
|
export const API_SERVICE_PROVIDERS = `${API_BASE_URL}/ServiceProviders`;
|
||||||
export const API_CARRIERS = `${API_BASE_URL}/VoipCarriers`;
|
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_SIP_GATEWAY = `${API_BASE_URL}/SipGateways`;
|
||||||
export const API_PASSWORD_SETTINGS = `${API_BASE_URL}/PasswordSettings`;
|
export const API_PASSWORD_SETTINGS = `${API_BASE_URL}/PasswordSettings`;
|
||||||
export const API_FORGOT_PASSWORD = `${API_BASE_URL}/forgot-password`;
|
export const API_FORGOT_PASSWORD = `${API_BASE_URL}/forgot-password`;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
API_MS_TEAMS_TENANTS,
|
API_MS_TEAMS_TENANTS,
|
||||||
API_PHONE_NUMBERS,
|
API_PHONE_NUMBERS,
|
||||||
API_CARRIERS,
|
API_CARRIERS,
|
||||||
API_SMPP_GATEWAY,
|
|
||||||
API_SIP_GATEWAY,
|
API_SIP_GATEWAY,
|
||||||
API_PASSWORD_SETTINGS,
|
API_PASSWORD_SETTINGS,
|
||||||
API_FORGOT_PASSWORD,
|
API_FORGOT_PASSWORD,
|
||||||
@@ -67,7 +66,6 @@ import type {
|
|||||||
MSTeamsTenant,
|
MSTeamsTenant,
|
||||||
PhoneNumber,
|
PhoneNumber,
|
||||||
Carrier,
|
Carrier,
|
||||||
SmppGateway,
|
|
||||||
SipGateway,
|
SipGateway,
|
||||||
TotalResponse,
|
TotalResponse,
|
||||||
CallQuery,
|
CallQuery,
|
||||||
@@ -394,13 +392,6 @@ export const postSipGateway = (payload: Partial<SipGateway>) => {
|
|||||||
return postFetch<SidResponse, Partial<SipGateway>>(API_SIP_GATEWAY, payload);
|
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 = (
|
export const postServiceProviderLimit = (
|
||||||
sid: string,
|
sid: string,
|
||||||
payload: Partial<Limit>,
|
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>) => {
|
export const putLcr = (sid: string, payload: Partial<Lcr>) => {
|
||||||
return putFetch<EmptyResponse, Partial<Lcr>>(`${API_LCRS}/${sid}`, payload);
|
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}`);
|
return deleteFetch<EmptyResponse>(`${API_SIP_GATEWAY}/${sid}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteSmppGateway = (sid: string) => {
|
|
||||||
return deleteFetch<EmptyResponse>(`${API_SMPP_GATEWAY}/${sid}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const deleteServiceProviderLimit = (
|
export const deleteServiceProviderLimit = (
|
||||||
sid: string,
|
sid: string,
|
||||||
cat: LimitCategories,
|
cat: LimitCategories,
|
||||||
|
|||||||
+1
-22
@@ -52,7 +52,7 @@ export enum StatusCodes {
|
|||||||
NOT_FOUND = 404,
|
NOT_FOUND = 404,
|
||||||
UNPROCESSABLE_ENTITY = 422,
|
UNPROCESSABLE_ENTITY = 422,
|
||||||
INTERNAL_SERVER_ERROR = 500,
|
INTERNAL_SERVER_ERROR = 500,
|
||||||
/** SMPP temporarily unavailable */
|
/** temporarily unavailable */
|
||||||
TEMPORARILY_UNAVAILABLE = 480,
|
TEMPORARILY_UNAVAILABLE = 480,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,15 +246,6 @@ export interface Sbc {
|
|||||||
service_provider_sid: null | string;
|
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 {
|
export interface Account {
|
||||||
name: string;
|
name: string;
|
||||||
sip_realm: null | string;
|
sip_realm: null | string;
|
||||||
@@ -492,11 +483,6 @@ export interface Carrier {
|
|||||||
diversion: null | string;
|
diversion: null | string;
|
||||||
inbound_auth_username: string;
|
inbound_auth_username: string;
|
||||||
inbound_auth_password: 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;
|
register_status: CarrierRegisterStatus;
|
||||||
dtmf_type: DtmfType;
|
dtmf_type: DtmfType;
|
||||||
outbound_sip_proxy: string | null;
|
outbound_sip_proxy: string | null;
|
||||||
@@ -528,13 +514,6 @@ export interface SipGateway extends Gateway {
|
|||||||
dtls_off?: boolean;
|
dtls_off?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SmppGateway extends Gateway {
|
|
||||||
smpp_gateway_sid?: null | string;
|
|
||||||
is_primary: boolean;
|
|
||||||
use_tls: boolean;
|
|
||||||
port: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Lcr {
|
export interface Lcr {
|
||||||
lcr_sid?: null | string;
|
lcr_sid?: null | string;
|
||||||
is_active: boolean;
|
is_active: boolean;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useApiData } from "src/api";
|
|||||||
import { useSelectState } from "src/store";
|
import { useSelectState } from "src/store";
|
||||||
import { CarrierForm } from "./form";
|
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 { useScopedRedirect } from "src/utils/use-scoped-redirect";
|
||||||
import { ROUTE_INTERNAL_CARRIERS } from "src/router/routes";
|
import { ROUTE_INTERNAL_CARRIERS } from "src/router/routes";
|
||||||
import { Scope } from "src/store/types";
|
import { Scope } from "src/store/types";
|
||||||
@@ -22,9 +22,6 @@ export const EditCarrier = () => {
|
|||||||
const [sipGateways, sipGatewaysRefetch] = useApiData<SipGateway[]>(
|
const [sipGateways, sipGatewaysRefetch] = useApiData<SipGateway[]>(
|
||||||
`SipGateways?voip_carrier_sid=${params.voip_carrier_sid}`,
|
`SipGateways?voip_carrier_sid=${params.voip_carrier_sid}`,
|
||||||
);
|
);
|
||||||
const [smppGateways, smppGatewaysRefetch] = useApiData<SmppGateway[]>(
|
|
||||||
`SmppGateways?voip_carrier_sid=${params.voip_carrier_sid}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
useScopedRedirect(
|
useScopedRedirect(
|
||||||
Scope.account,
|
Scope.account,
|
||||||
@@ -49,10 +46,6 @@ export const EditCarrier = () => {
|
|||||||
data: sipGateways,
|
data: sipGateways,
|
||||||
refetch: sipGatewaysRefetch,
|
refetch: sipGatewaysRefetch,
|
||||||
}}
|
}}
|
||||||
carrierSmppGateways={{
|
|
||||||
data: smppGateways,
|
|
||||||
refetch: smppGatewaysRefetch,
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ import {
|
|||||||
deleteSipGateway,
|
deleteSipGateway,
|
||||||
postCarrier,
|
postCarrier,
|
||||||
postSipGateway,
|
postSipGateway,
|
||||||
postSmppGateway,
|
|
||||||
putCarrier,
|
putCarrier,
|
||||||
putSipGateway,
|
putSipGateway,
|
||||||
putSmppGateway,
|
|
||||||
useApiData,
|
useApiData,
|
||||||
useServiceProviderData,
|
useServiceProviderData,
|
||||||
postPredefinedCarrierTemplate,
|
postPredefinedCarrierTemplate,
|
||||||
@@ -17,10 +15,8 @@ import {
|
|||||||
} from "src/api";
|
} from "src/api";
|
||||||
import {
|
import {
|
||||||
DEFAULT_SIP_INBOUND_GATEWAY,
|
DEFAULT_SIP_INBOUND_GATEWAY,
|
||||||
DEFAULT_SMPP_GATEWAY,
|
|
||||||
DTMF_TYPE_SELECTION,
|
DTMF_TYPE_SELECTION,
|
||||||
FQDN,
|
FQDN,
|
||||||
FQDN_TOP_LEVEL,
|
|
||||||
INVALID,
|
INVALID,
|
||||||
IP,
|
IP,
|
||||||
NETMASK_OPTIONS,
|
NETMASK_OPTIONS,
|
||||||
@@ -58,7 +54,6 @@ import {
|
|||||||
type UseApiDataMap,
|
type UseApiDataMap,
|
||||||
type Carrier,
|
type Carrier,
|
||||||
type SipGateway,
|
type SipGateway,
|
||||||
type SmppGateway,
|
|
||||||
type PredefinedCarrier,
|
type PredefinedCarrier,
|
||||||
type Sbc,
|
type Sbc,
|
||||||
type Application,
|
type Application,
|
||||||
@@ -72,13 +67,11 @@ import { useToast } from "src/components/toast/toast-provider";
|
|||||||
type CarrierFormProps = {
|
type CarrierFormProps = {
|
||||||
carrier?: UseApiDataMap<Carrier>;
|
carrier?: UseApiDataMap<Carrier>;
|
||||||
carrierSipGateways?: UseApiDataMap<SipGateway[]>;
|
carrierSipGateways?: UseApiDataMap<SipGateway[]>;
|
||||||
carrierSmppGateways?: UseApiDataMap<SmppGateway[]>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CarrierForm = ({
|
export const CarrierForm = ({
|
||||||
carrier,
|
carrier,
|
||||||
carrierSipGateways,
|
carrierSipGateways,
|
||||||
carrierSmppGateways,
|
|
||||||
}: CarrierFormProps) => {
|
}: CarrierFormProps) => {
|
||||||
const { toastSuccess, toastError } = useToast();
|
const { toastSuccess, toastError } = useToast();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -88,7 +81,6 @@ export const CarrierForm = ({
|
|||||||
const refSipInboundIp = useRef<HTMLInputElement[]>([]);
|
const refSipInboundIp = useRef<HTMLInputElement[]>([]);
|
||||||
const refSipOutboundIp = useRef<HTMLInputElement[]>([]);
|
const refSipOutboundIp = useRef<HTMLInputElement[]>([]);
|
||||||
const refSipPort = useRef<HTMLInputElement[]>([]);
|
const refSipPort = useRef<HTMLInputElement[]>([]);
|
||||||
const refSmppIp = useRef<HTMLInputElement[]>([]);
|
|
||||||
const refInboundAuthUsername = useRef<HTMLInputElement>(null);
|
const refInboundAuthUsername = useRef<HTMLInputElement>(null);
|
||||||
const [sbcs] = useApiData<Sbc[]>("Sbcs");
|
const [sbcs] = useApiData<Sbc[]>("Sbcs");
|
||||||
const [applications] = useServiceProviderData<Application[]>("Applications");
|
const [applications] = useServiceProviderData<Application[]>("Applications");
|
||||||
@@ -128,11 +120,6 @@ export const CarrierForm = ({
|
|||||||
const [initialRegister, setInitialRegister] = useState(false);
|
const [initialRegister, setInitialRegister] = useState(false);
|
||||||
const [initialSipRegister, setInitialSipRegister] = 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[]>(
|
const [sipInboundGateways, setSipInboundGateways] = useState<SipGateway[]>(
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
@@ -145,16 +132,6 @@ export const CarrierForm = ({
|
|||||||
const [tmpOutboundGateways, setTmpOutboundGateways] = useState<SipGateway[]>(
|
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 [sipInboundMessage, setSipInboundMessage] = useState("");
|
||||||
const [sipOutboundMessage, setSipOutboundMessage] = useState("");
|
const [sipOutboundMessage, setSipOutboundMessage] = useState("");
|
||||||
@@ -305,18 +282,6 @@ export const CarrierForm = ({
|
|||||||
setInitialSipRegister(false);
|
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) {
|
if (obj.dtmf_type) {
|
||||||
setDtmfType(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 = (
|
const updateSipInboundGateways = (
|
||||||
index: number,
|
index: number,
|
||||||
key: string,
|
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) => {
|
const handleSipGatewayDelete = (g?: SipGateway) => {
|
||||||
if (g && g.sip_gateway_sid) {
|
if (g && g.sip_gateway_sid) {
|
||||||
deleteSipGateway(g.sip_gateway_sid).then(() =>
|
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 = () => {
|
const getSipValidation = () => {
|
||||||
if (
|
if (
|
||||||
trunkType === "static_ip" &&
|
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 handleActiveTab = () => {
|
||||||
const gatewaysToCheck =
|
const gatewaysToCheck =
|
||||||
trunkType === "auth"
|
trunkType === "auth"
|
||||||
@@ -658,25 +529,6 @@ export const CarrierForm = ({
|
|||||||
setActiveTab("sip");
|
setActiveTab("sip");
|
||||||
return; /** Important so browser contstraints work properly */
|
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) => {
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
@@ -743,10 +595,6 @@ export const CarrierForm = ({
|
|||||||
tech_prefix: prefix.trim() || null,
|
tech_prefix: prefix.trim() || null,
|
||||||
diversion: diversion.trim() || null,
|
diversion: diversion.trim() || null,
|
||||||
is_active: isActive,
|
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,
|
dtmf_type: dtmfType,
|
||||||
trunk_type: trunkType,
|
trunk_type: trunkType,
|
||||||
inbound_auth_username: inboundAuthUsername.trim() || undefined,
|
inbound_auth_username: inboundAuthUsername.trim() || undefined,
|
||||||
@@ -763,7 +611,6 @@ export const CarrierForm = ({
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
if (carrier.data?.voip_carrier_sid) {
|
if (carrier.data?.voip_carrier_sid) {
|
||||||
handleSipGatewayPutPost(carrier.data.voip_carrier_sid);
|
handleSipGatewayPutPost(carrier.data.voip_carrier_sid);
|
||||||
handleSmppGatewayPutPost(carrier.data.voip_carrier_sid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toastSuccess("Carrier updated successfully");
|
toastSuccess("Carrier updated successfully");
|
||||||
@@ -782,7 +629,6 @@ export const CarrierForm = ({
|
|||||||
})
|
})
|
||||||
.then(({ json }) => {
|
.then(({ json }) => {
|
||||||
handleSipGatewayPutPost(json.sid);
|
handleSipGatewayPutPost(json.sid);
|
||||||
handleSmppGatewayPutPost(json.sid);
|
|
||||||
|
|
||||||
toastSuccess("Carrier created successfully");
|
toastSuccess("Carrier created successfully");
|
||||||
navigate(ROUTE_INTERNAL_CARRIERS);
|
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 */
|
/** 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 */
|
/** https://beta.reactjs.org/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes */
|
||||||
const [prevSipGateways, setPrevSipGateways] = useState<SipGateway[]>();
|
const [prevSipGateways, setPrevSipGateways] = useState<SipGateway[]>();
|
||||||
const [prevSmppGateways, setPrevSmppGateways] = useState<SmppGateway[]>();
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
carrierSipGateways &&
|
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 handleInvalidField = (e: React.InvalidEvent<HTMLFormElement>) => {
|
||||||
const invalidField = e.target as unknown as HTMLInputElement;
|
const invalidField = e.target as unknown as HTMLInputElement;
|
||||||
const fieldName = invalidField.name || invalidField.id;
|
const fieldName = invalidField.name || invalidField.id;
|
||||||
@@ -889,8 +714,6 @@ export const CarrierForm = ({
|
|||||||
targetTab = "inbound";
|
targetTab = "inbound";
|
||||||
} else if (fieldName?.includes("sip_") || fieldName?.includes("from_")) {
|
} else if (fieldName?.includes("sip_") || fieldName?.includes("from_")) {
|
||||||
targetTab = "outbound";
|
targetTab = "outbound";
|
||||||
} else if (fieldName?.includes("smpp_")) {
|
|
||||||
targetTab = "smpp";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not on the right tab, switch to it
|
// 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 {
|
import {
|
||||||
deleteCarrier,
|
deleteCarrier,
|
||||||
deleteSipGateway,
|
deleteSipGateway,
|
||||||
deleteSmppGateway,
|
|
||||||
getFetch,
|
getFetch,
|
||||||
getSPVoipCarriers,
|
getSPVoipCarriers,
|
||||||
useApiData,
|
useApiData,
|
||||||
@@ -26,7 +25,6 @@ import { Gateways } from "./gateways";
|
|||||||
import { isUserAccountScope, hasLength, hasValue } from "src/utils";
|
import { isUserAccountScope, hasLength, hasValue } from "src/utils";
|
||||||
import {
|
import {
|
||||||
API_SIP_GATEWAY,
|
API_SIP_GATEWAY,
|
||||||
API_SMPP_GATEWAY,
|
|
||||||
CARRIER_REG_OK,
|
CARRIER_REG_OK,
|
||||||
ENABLE_HOSTED_SYSTEM,
|
ENABLE_HOSTED_SYSTEM,
|
||||||
PER_PAGE_SELECTION,
|
PER_PAGE_SELECTION,
|
||||||
@@ -42,7 +40,6 @@ import type {
|
|||||||
Carrier,
|
Carrier,
|
||||||
CurrentUserData,
|
CurrentUserData,
|
||||||
SipGateway,
|
SipGateway,
|
||||||
SmppGateway,
|
|
||||||
} from "src/api/types";
|
} from "src/api/types";
|
||||||
import { Scope } from "src/store/types";
|
import { Scope } from "src/store/types";
|
||||||
import { getAccountFilter, setLocation } from "src/store/localStore";
|
import { getAccountFilter, setLocation } from "src/store/localStore";
|
||||||
@@ -112,14 +109,9 @@ export const Carriers = () => {
|
|||||||
|
|
||||||
deleteCarrier(carrier.voip_carrier_sid)
|
deleteCarrier(carrier.voip_carrier_sid)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
Promise.all([
|
getFetch<SipGateway[]>(
|
||||||
getFetch<SipGateway[]>(
|
`${API_SIP_GATEWAY}?voip_carrier_sid=${carrier.voip_carrier_sid}`,
|
||||||
`${API_SIP_GATEWAY}?voip_carrier_sid=${carrier.voip_carrier_sid}`,
|
).then((sipGatewaysRes) => {
|
||||||
),
|
|
||||||
getFetch<SmppGateway[]>(
|
|
||||||
`${API_SMPP_GATEWAY}?voip_carrier_sid=${carrier.voip_carrier_sid}`,
|
|
||||||
),
|
|
||||||
]).then(([sipGatewaysRes, smppGatewaysRes]) => {
|
|
||||||
hasLength(sipGatewaysRes.json) &&
|
hasLength(sipGatewaysRes.json) &&
|
||||||
sipGatewaysRes.json.forEach(
|
sipGatewaysRes.json.forEach(
|
||||||
(g) =>
|
(g) =>
|
||||||
@@ -129,15 +121,6 @@ export const Carriers = () => {
|
|||||||
toastError(error.msg),
|
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);
|
setCarrier(null);
|
||||||
fetchCarriers(false);
|
fetchCarriers(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user