@vgroup/dialbox 0.2.29 → 0.2.30

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.
@@ -563,45 +563,21 @@ 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
- */
579
566
  initiateCall(payload) {
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$]);
567
+ return this.fetchBlockedCountries().pipe(switchMap(blockedCountries => {
568
+ return this.ipAddressService.getIpAddressInfo().pipe(switchMap(ipAddressInfo => {
569
+ const params = {
570
+ 'Content-Type': 'application/json',
571
+ 'Auth-Key': 'Bearer ' + localStorage.getItem('ext_token'),
572
+ 'ip-address': ipAddressInfo.ip,
573
+ 'ip-country': ipAddressInfo.address.country,
574
+ };
575
+ payload = Object.assign(Object.assign({}, payload), { proxy: ipAddressInfo.proxy.toString() });
576
+ const httpOptions = { headers: new HttpHeaders(params) };
577
+ const api1$ = this.http.post(`${environment.apiUrl}/utilities/ext/ur/initiate/call`, payload, httpOptions);
578
+ const api2$ = this.http.post(`${environment.apiUrl}/utilities/ext/ur/initiate/conference/call`, payload, httpOptions);
579
+ return forkJoin([api1$, api2$]).pipe(catchError(error => throwError(() => error)));
580
+ }), catchError(error => throwError(() => error)));
605
581
  }));
606
582
  }
607
583
  getConferenceCallToken(payload) {
@@ -2124,8 +2100,8 @@ class CallProgressComponent {
2124
2100
  scope: 'local',
2125
2101
  fromNumber: callData.from
2126
2102
  };
2127
- const [response] = yield this.initiateCall(payload);
2128
- if (response && response.status === 200) {
2103
+ const response = yield this.initiateCall(payload);
2104
+ if (response.status == 200) {
2129
2105
  const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
2130
2106
  this.getUserInformation(callAuthId);
2131
2107
  this.recordCall = recordCall; // Store the recordCall value
@@ -2134,7 +2110,7 @@ class CallProgressComponent {
2134
2110
  // Poll the status for 30-45 seconds
2135
2111
  this.pollCallStatus(callAuthId);
2136
2112
  }
2137
- else if (response && response.status === 201) {
2113
+ else if (response.status == 201) {
2138
2114
  swal("Error", response.message.join("<br/>"), "error");
2139
2115
  console.log('test2');
2140
2116
  this.endCall();
@@ -2387,8 +2363,8 @@ class CallProgressComponent {
2387
2363
  scope: 'local',
2388
2364
  fromNumber: this.callData.from
2389
2365
  };
2390
- const [response] = yield this.initiateCall(payload);
2391
- if (response && response.status === 200) {
2366
+ const response = yield this.initiateCall(payload);
2367
+ if (response.status == 200) {
2392
2368
  const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
2393
2369
  this.getUserInformation(callAuthId);
2394
2370
  this.recordCall = recordCall;
@@ -2434,7 +2410,7 @@ class CallProgressComponent {
2434
2410
  console.log('New call initiated to:', phoneNumber);
2435
2411
  this.cdr.detectChanges();
2436
2412
  }
2437
- else if (response && response.status === 201) {
2413
+ else if (response.status == 201) {
2438
2414
  swal("Error", response.message.join("<br/>"), "error");
2439
2415
  // Restore held call if new call fails
2440
2416
  if (this.heldCall) {