@vgroup/dialbox 0.2.29 → 0.2.31
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 +11 -11
- package/esm2020/lib/service/extension.service.mjs +63 -44
- package/fesm2015/vgroup-dialbox.mjs +72 -52
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +72 -52
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/call-progress.component.d.ts +1 -1
- package/lib/service/extension.service.d.ts +1 -14
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, NgModule } from '@angular/core';
|
|
3
3
|
import swal from 'sweetalert2';
|
|
4
4
|
import { AsYouType } from 'libphonenumber-js';
|
|
5
|
-
import { throwError, BehaviorSubject,
|
|
5
|
+
import { throwError, BehaviorSubject, of, interval, Subscription } from 'rxjs';
|
|
6
6
|
import * as i1 from '@angular/common/http';
|
|
7
7
|
import { HttpHeaders, HttpParams, HttpClientModule } from '@angular/common/http';
|
|
8
8
|
import { catchError, switchMap, map, tap, shareReplay } from 'rxjs/operators';
|
|
@@ -562,54 +562,74 @@ 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
|
-
*/
|
|
578
565
|
initiateCall(payload) {
|
|
579
|
-
return
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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$]);
|
|
566
|
+
return this.fetchBlockedCountries().pipe(switchMap(blockedCountries => {
|
|
567
|
+
return this.ipAddressService.getIpAddressInfo().pipe(switchMap(ipAddressInfo => {
|
|
568
|
+
const params = {
|
|
569
|
+
'Content-Type': 'application/json',
|
|
570
|
+
'Auth-Key': 'Bearer ' + localStorage.getItem('ext_token'),
|
|
571
|
+
'ip-address': ipAddressInfo.ip,
|
|
572
|
+
'ip-country': ipAddressInfo.address.country,
|
|
573
|
+
};
|
|
574
|
+
payload = { ...payload, proxy: ipAddressInfo.proxy.toString() };
|
|
575
|
+
const httpOptions = { headers: new HttpHeaders(params) };
|
|
576
|
+
return this.http.post(environment.apiUrl + '/utilities/ext/ur/initiate/conference/call', payload, httpOptions).pipe(catchError(error => {
|
|
577
|
+
return throwError(error);
|
|
578
|
+
}));
|
|
579
|
+
}), catchError(error => {
|
|
580
|
+
// Catch error from getIpAddressInfo
|
|
581
|
+
return throwError(error);
|
|
582
|
+
}));
|
|
604
583
|
}));
|
|
605
584
|
}
|
|
585
|
+
// initiateCall(payload: any): Observable<any> {
|
|
586
|
+
// return this.fetchBlockedCountries().pipe(
|
|
587
|
+
// switchMap(blockedCountries => {
|
|
588
|
+
// return this.ipAddressService.getIpAddressInfo().pipe(
|
|
589
|
+
// switchMap(ipAddressInfo => {
|
|
590
|
+
// const params = {
|
|
591
|
+
// 'Content-Type': 'application/json',
|
|
592
|
+
// 'Auth-Key': 'Bearer ' + localStorage.getItem('ext_token'),
|
|
593
|
+
// 'ip-address': ipAddressInfo.ip,
|
|
594
|
+
// 'ip-country': ipAddressInfo.address.country,
|
|
595
|
+
// };
|
|
596
|
+
// payload = { ...payload, proxy: ipAddressInfo.proxy.toString() };
|
|
597
|
+
// const httpOptions = { headers: new HttpHeaders(params) };
|
|
598
|
+
// const api1$ = this.http.post(
|
|
599
|
+
// `${environment.apiUrl}/utilities/ext/ur/initiate/call`,
|
|
600
|
+
// payload,
|
|
601
|
+
// httpOptions
|
|
602
|
+
// );
|
|
603
|
+
// const api2$ = this.http.post(
|
|
604
|
+
// `${environment.apiUrl}/utilities/ext/ur/initiate/conference/call`,
|
|
605
|
+
// payload,
|
|
606
|
+
// httpOptions
|
|
607
|
+
// );
|
|
608
|
+
// return forkJoin([api1$, api2$]).pipe(
|
|
609
|
+
// catchError(error => throwError(() => error))
|
|
610
|
+
// );
|
|
611
|
+
// }),
|
|
612
|
+
// catchError(error => throwError(() => error))
|
|
613
|
+
// );
|
|
614
|
+
// })
|
|
615
|
+
// );
|
|
616
|
+
// }
|
|
617
|
+
// getConferenceCallToken(payload: any) {
|
|
618
|
+
// const params = {
|
|
619
|
+
// "conferenceId": payload.conferenceId,
|
|
620
|
+
// "userId": payload.userId
|
|
621
|
+
// }
|
|
622
|
+
// const httpOptions = { headers: new HttpHeaders(params) };
|
|
623
|
+
// return this.http.post<[]>(environment.apiUrl + '/utilities/ext/ur/generate/conference/token', params, httpOptions);
|
|
624
|
+
// }
|
|
606
625
|
getConferenceCallToken(payload) {
|
|
607
626
|
const params = {
|
|
608
|
-
|
|
609
|
-
"
|
|
627
|
+
'Content-Type': 'application/json',
|
|
628
|
+
'Auth-Key': "Bearer " + localStorage.getItem('ext_token'),
|
|
629
|
+
'c2c-request': window.location.hostname
|
|
610
630
|
};
|
|
611
631
|
const httpOptions = { headers: new HttpHeaders(params) };
|
|
612
|
-
return this.http.post(environment.apiUrl + '/ur/generate/
|
|
632
|
+
return this.http.post(environment.apiUrl + '/utilities/ext/ur/generate/token', payload, httpOptions);
|
|
613
633
|
}
|
|
614
634
|
addFirstParticipant(payload) {
|
|
615
635
|
const params = {
|
|
@@ -2120,17 +2140,17 @@ class CallProgressComponent {
|
|
|
2120
2140
|
scope: 'local',
|
|
2121
2141
|
fromNumber: callData.from
|
|
2122
2142
|
};
|
|
2123
|
-
const
|
|
2124
|
-
if (response
|
|
2143
|
+
const response = await this.initiateCall(payload);
|
|
2144
|
+
if (response.status == 200) {
|
|
2125
2145
|
const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2126
2146
|
this.getUserInformation(callAuthId);
|
|
2127
2147
|
this.recordCall = recordCall; // Store the recordCall value
|
|
2128
|
-
const tokenData = await this.
|
|
2148
|
+
const tokenData = await this.getConferenceCallToken(callAuthId);
|
|
2129
2149
|
await this.connectToDevice(tokenData.token, callData);
|
|
2130
2150
|
// Poll the status for 30-45 seconds
|
|
2131
2151
|
this.pollCallStatus(callAuthId);
|
|
2132
2152
|
}
|
|
2133
|
-
else if (response
|
|
2153
|
+
else if (response.status == 201) {
|
|
2134
2154
|
swal("Error", response.message.join("<br/>"), "error");
|
|
2135
2155
|
console.log('test2');
|
|
2136
2156
|
this.endCall();
|
|
@@ -2152,8 +2172,8 @@ class CallProgressComponent {
|
|
|
2152
2172
|
recordCall: response.callauth.recordCall
|
|
2153
2173
|
};
|
|
2154
2174
|
}
|
|
2155
|
-
async
|
|
2156
|
-
return await this.extensionService.
|
|
2175
|
+
async getConferenceCallToken(callAuthId) {
|
|
2176
|
+
return await this.extensionService.getConferenceCallToken({ authId: callAuthId }).toPromise();
|
|
2157
2177
|
}
|
|
2158
2178
|
async connectToDevice(token, callData) {
|
|
2159
2179
|
const options = {
|
|
@@ -2369,12 +2389,12 @@ class CallProgressComponent {
|
|
|
2369
2389
|
scope: 'local',
|
|
2370
2390
|
fromNumber: this.callData.from
|
|
2371
2391
|
};
|
|
2372
|
-
const
|
|
2373
|
-
if (response
|
|
2392
|
+
const response = await this.initiateCall(payload);
|
|
2393
|
+
if (response.status == 200) {
|
|
2374
2394
|
const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2375
2395
|
this.getUserInformation(callAuthId);
|
|
2376
2396
|
this.recordCall = recordCall;
|
|
2377
|
-
const tokenData = await this.
|
|
2397
|
+
const tokenData = await this.getConferenceCallToken(callAuthId);
|
|
2378
2398
|
// Connect to new call
|
|
2379
2399
|
const options = {
|
|
2380
2400
|
codecPreferences: ['opus', 'pcmu'],
|
|
@@ -2416,7 +2436,7 @@ class CallProgressComponent {
|
|
|
2416
2436
|
console.log('New call initiated to:', phoneNumber);
|
|
2417
2437
|
this.cdr.detectChanges();
|
|
2418
2438
|
}
|
|
2419
|
-
else if (response
|
|
2439
|
+
else if (response.status == 201) {
|
|
2420
2440
|
swal("Error", response.message.join("<br/>"), "error");
|
|
2421
2441
|
// Restore held call if new call fails
|
|
2422
2442
|
if (this.heldCall) {
|