fix: download pcap (#258)

This commit is contained in:
Hoan Luu Huu
2023-05-24 18:56:15 +07:00
committed by GitHub
parent fffd86619d
commit af37066201
3 changed files with 13 additions and 9 deletions
+10 -6
View File
@@ -635,11 +635,11 @@ export const getRecentCall = (sid: string, sipCallId: string) => {
);
};
export const getPcap = (sid: string, sipCallId: string) => {
export const getPcap = (sid: string, sipCallId: string, method: string) => {
return getBlob(
import.meta.env.DEV
? `${DEV_BASE_URL}/Accounts/${sid}/RecentCalls/${sipCallId}/pcap`
: `${API_ACCOUNTS}/${sid}/RecentCalls/${sipCallId}/pcap`
? `${DEV_BASE_URL}/Accounts/${sid}/RecentCalls/${sipCallId}/${method}/pcap`
: `${API_ACCOUNTS}/${sid}/RecentCalls/${sipCallId}/${method}/pcap`
);
};
@@ -662,11 +662,15 @@ export const getServiceProviderRecentCall = (
);
};
export const getServiceProviderPcap = (sid: string, sipCallId: string) => {
export const getServiceProviderPcap = (
sid: string,
sipCallId: string,
method: string
) => {
return getBlob(
import.meta.env.DEV
? `${DEV_BASE_URL}/ServiceProviders/${sid}/RecentCalls/${sipCallId}/pcap`
: `${API_SERVICE_PROVIDERS}/${sid}/RecentCalls/${sipCallId}/pcap`
? `${DEV_BASE_URL}/ServiceProviders/${sid}/RecentCalls/${sipCallId}/${method}/pcap`
: `${API_SERVICE_PROVIDERS}/${sid}/RecentCalls/${sipCallId}/${method}/pcap`
);
};
@@ -31,8 +31,8 @@ export const PcapButton = ({
p.then(({ json }) => {
if (json.total > 0) {
const p1 = accountSid
? getPcap(accountSid, sipCallId)
: getServiceProviderPcap(serviceProviderSid, sipCallId);
? getPcap(accountSid, sipCallId, "register")
: getServiceProviderPcap(serviceProviderSid, sipCallId, "register");
p1.then(({ blob }) => {
if (blob) {
setPcap({
@@ -13,7 +13,7 @@ export const PcapButton = ({ call }: PcapButtonProps) => {
const [pcap, setPcap] = useState<Pcap>();
useEffect(() => {
getPcap(call.account_sid, call.sip_callid)
getPcap(call.account_sid, call.sip_callid, "invite")
.then(({ blob }) => {
if (blob) {
setPcap({