@vgroup/dialbox 0.2.28 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/call-progress/call-progress.component.mjs +7 -7
- package/esm2020/lib/service/extension.service.mjs +40 -16
- package/fesm2015/vgroup-dialbox.mjs +44 -20
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +44 -20
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/service/extension.service.d.ts +14 -1
- package/package.json +1 -1
|
@@ -563,21 +563,45 @@ class ExtensionService {
|
|
|
563
563
|
// })
|
|
564
564
|
// );
|
|
565
565
|
// }
|
|
566
|
+
/**
|
|
567
|
+
* Initiates a normal & a conference call in parallel.
|
|
568
|
+
* The method performs three steps:
|
|
569
|
+
* 1. Load black-listed countries & current IP info in parallel.
|
|
570
|
+
* 2. Abort early if the caller is from a blocked country.
|
|
571
|
+
* 3. Fire both call-initiation APIs together and return both responses.
|
|
572
|
+
*
|
|
573
|
+
* It guarantees that:
|
|
574
|
+
* • Both HTTP requests are always attempted.
|
|
575
|
+
* • Failure of one request does not cancel the other – the error is
|
|
576
|
+
* returned alongside the success response so that the component can
|
|
577
|
+
* decide what to do.
|
|
578
|
+
*/
|
|
566
579
|
initiateCall(payload) {
|
|
567
|
-
return
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
580
|
+
return forkJoin({
|
|
581
|
+
blocked: this.fetchBlockedCountries(),
|
|
582
|
+
ipInfo: this.ipAddressService.getIpAddressInfo()
|
|
583
|
+
}).pipe(switchMap(({ blocked, ipInfo }) => {
|
|
584
|
+
// Reject early if user’s country is in the blocked list.
|
|
585
|
+
if (blocked.includes(ipInfo.address.countryCode)) {
|
|
586
|
+
return throwError(() => ({ message: ['User from blocked country'] }));
|
|
587
|
+
}
|
|
588
|
+
// Prepare headers & body for both requests.
|
|
589
|
+
const headers = new HttpHeaders({
|
|
590
|
+
'Content-Type': 'application/json',
|
|
591
|
+
'Auth-Key': 'Bearer ' + localStorage.getItem('ext_token'),
|
|
592
|
+
'ip-address': ipInfo.ip,
|
|
593
|
+
'ip-country': ipInfo.address.country
|
|
594
|
+
});
|
|
595
|
+
const body = Object.assign(Object.assign({}, payload), { proxy: ipInfo.proxy.toString() });
|
|
596
|
+
const options = { headers };
|
|
597
|
+
const api1$ = this.http
|
|
598
|
+
.post(`${environment.apiUrl}/utilities/ext/ur/initiate/call`, body, options)
|
|
599
|
+
.pipe(catchError(error => of({ error })));
|
|
600
|
+
const api2$ = this.http
|
|
601
|
+
.post(`${environment.apiUrl}/ur/initiate/conference/call`, body, options)
|
|
602
|
+
.pipe(catchError(error => of({ error })));
|
|
603
|
+
// Execute both requests and return their individual outcomes.
|
|
604
|
+
return forkJoin([api1$, api2$]);
|
|
581
605
|
}));
|
|
582
606
|
}
|
|
583
607
|
getConferenceCallToken(payload) {
|
|
@@ -2100,8 +2124,8 @@ class CallProgressComponent {
|
|
|
2100
2124
|
scope: 'local',
|
|
2101
2125
|
fromNumber: callData.from
|
|
2102
2126
|
};
|
|
2103
|
-
const response = yield this.initiateCall(payload);
|
|
2104
|
-
if (response.status
|
|
2127
|
+
const [response] = yield this.initiateCall(payload);
|
|
2128
|
+
if (response && response.status === 200) {
|
|
2105
2129
|
const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
|
|
2106
2130
|
this.getUserInformation(callAuthId);
|
|
2107
2131
|
this.recordCall = recordCall; // Store the recordCall value
|
|
@@ -2110,7 +2134,7 @@ class CallProgressComponent {
|
|
|
2110
2134
|
// Poll the status for 30-45 seconds
|
|
2111
2135
|
this.pollCallStatus(callAuthId);
|
|
2112
2136
|
}
|
|
2113
|
-
else if (response.status
|
|
2137
|
+
else if (response && response.status === 201) {
|
|
2114
2138
|
swal("Error", response.message.join("<br/>"), "error");
|
|
2115
2139
|
console.log('test2');
|
|
2116
2140
|
this.endCall();
|
|
@@ -2363,8 +2387,8 @@ class CallProgressComponent {
|
|
|
2363
2387
|
scope: 'local',
|
|
2364
2388
|
fromNumber: this.callData.from
|
|
2365
2389
|
};
|
|
2366
|
-
const response = yield this.initiateCall(payload);
|
|
2367
|
-
if (response.status
|
|
2390
|
+
const [response] = yield this.initiateCall(payload);
|
|
2391
|
+
if (response && response.status === 200) {
|
|
2368
2392
|
const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
|
|
2369
2393
|
this.getUserInformation(callAuthId);
|
|
2370
2394
|
this.recordCall = recordCall;
|
|
@@ -2410,7 +2434,7 @@ class CallProgressComponent {
|
|
|
2410
2434
|
console.log('New call initiated to:', phoneNumber);
|
|
2411
2435
|
this.cdr.detectChanges();
|
|
2412
2436
|
}
|
|
2413
|
-
else if (response.status
|
|
2437
|
+
else if (response && response.status === 201) {
|
|
2414
2438
|
swal("Error", response.message.join("<br/>"), "error");
|
|
2415
2439
|
// Restore held call if new call fails
|
|
2416
2440
|
if (this.heldCall) {
|