@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
|
@@ -562,21 +562,45 @@ class ExtensionService {
|
|
|
562
562
|
// })
|
|
563
563
|
// );
|
|
564
564
|
// }
|
|
565
|
+
/**
|
|
566
|
+
* Initiates a normal & a conference call in parallel.
|
|
567
|
+
* The method performs three steps:
|
|
568
|
+
* 1. Load black-listed countries & current IP info in parallel.
|
|
569
|
+
* 2. Abort early if the caller is from a blocked country.
|
|
570
|
+
* 3. Fire both call-initiation APIs together and return both responses.
|
|
571
|
+
*
|
|
572
|
+
* It guarantees that:
|
|
573
|
+
* • Both HTTP requests are always attempted.
|
|
574
|
+
* • Failure of one request does not cancel the other – the error is
|
|
575
|
+
* returned alongside the success response so that the component can
|
|
576
|
+
* decide what to do.
|
|
577
|
+
*/
|
|
565
578
|
initiateCall(payload) {
|
|
566
|
-
return
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
579
|
+
return forkJoin({
|
|
580
|
+
blocked: this.fetchBlockedCountries(),
|
|
581
|
+
ipInfo: this.ipAddressService.getIpAddressInfo()
|
|
582
|
+
}).pipe(switchMap(({ blocked, ipInfo }) => {
|
|
583
|
+
// Reject early if user’s country is in the blocked list.
|
|
584
|
+
if (blocked.includes(ipInfo.address.countryCode)) {
|
|
585
|
+
return throwError(() => ({ message: ['User from blocked country'] }));
|
|
586
|
+
}
|
|
587
|
+
// Prepare headers & body for both requests.
|
|
588
|
+
const headers = new HttpHeaders({
|
|
589
|
+
'Content-Type': 'application/json',
|
|
590
|
+
'Auth-Key': 'Bearer ' + localStorage.getItem('ext_token'),
|
|
591
|
+
'ip-address': ipInfo.ip,
|
|
592
|
+
'ip-country': ipInfo.address.country
|
|
593
|
+
});
|
|
594
|
+
const body = { ...payload, proxy: ipInfo.proxy.toString() };
|
|
595
|
+
const options = { headers };
|
|
596
|
+
const api1$ = this.http
|
|
597
|
+
.post(`${environment.apiUrl}/utilities/ext/ur/initiate/call`, body, options)
|
|
598
|
+
.pipe(catchError(error => of({ error })));
|
|
599
|
+
const api2$ = this.http
|
|
600
|
+
.post(`${environment.apiUrl}/ur/initiate/conference/call`, body, options)
|
|
601
|
+
.pipe(catchError(error => of({ error })));
|
|
602
|
+
// Execute both requests and return their individual outcomes.
|
|
603
|
+
return forkJoin([api1$, api2$]);
|
|
580
604
|
}));
|
|
581
605
|
}
|
|
582
606
|
getConferenceCallToken(payload) {
|
|
@@ -2096,8 +2120,8 @@ class CallProgressComponent {
|
|
|
2096
2120
|
scope: 'local',
|
|
2097
2121
|
fromNumber: callData.from
|
|
2098
2122
|
};
|
|
2099
|
-
const response = await this.initiateCall(payload);
|
|
2100
|
-
if (response.status
|
|
2123
|
+
const [response] = await this.initiateCall(payload);
|
|
2124
|
+
if (response && response.status === 200) {
|
|
2101
2125
|
const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2102
2126
|
this.getUserInformation(callAuthId);
|
|
2103
2127
|
this.recordCall = recordCall; // Store the recordCall value
|
|
@@ -2106,7 +2130,7 @@ class CallProgressComponent {
|
|
|
2106
2130
|
// Poll the status for 30-45 seconds
|
|
2107
2131
|
this.pollCallStatus(callAuthId);
|
|
2108
2132
|
}
|
|
2109
|
-
else if (response.status
|
|
2133
|
+
else if (response && response.status === 201) {
|
|
2110
2134
|
swal("Error", response.message.join("<br/>"), "error");
|
|
2111
2135
|
console.log('test2');
|
|
2112
2136
|
this.endCall();
|
|
@@ -2345,8 +2369,8 @@ class CallProgressComponent {
|
|
|
2345
2369
|
scope: 'local',
|
|
2346
2370
|
fromNumber: this.callData.from
|
|
2347
2371
|
};
|
|
2348
|
-
const response = await this.initiateCall(payload);
|
|
2349
|
-
if (response.status
|
|
2372
|
+
const [response] = await this.initiateCall(payload);
|
|
2373
|
+
if (response && response.status === 200) {
|
|
2350
2374
|
const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2351
2375
|
this.getUserInformation(callAuthId);
|
|
2352
2376
|
this.recordCall = recordCall;
|
|
@@ -2392,7 +2416,7 @@ class CallProgressComponent {
|
|
|
2392
2416
|
console.log('New call initiated to:', phoneNumber);
|
|
2393
2417
|
this.cdr.detectChanges();
|
|
2394
2418
|
}
|
|
2395
|
-
else if (response.status
|
|
2419
|
+
else if (response && response.status === 201) {
|
|
2396
2420
|
swal("Error", response.message.join("<br/>"), "error");
|
|
2397
2421
|
// Restore held call if new call fails
|
|
2398
2422
|
if (this.heldCall) {
|