@webex/calling 0.0.1-next.0
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/README.md +67 -0
- package/dist/module/CallHistory/CallHistory.js +84 -0
- package/dist/module/CallHistory/callHistoryFixtures.js +307 -0
- package/dist/module/CallHistory/constants.js +9 -0
- package/dist/module/CallHistory/types.js +1 -0
- package/dist/module/CallSettings/CallSettings.js +65 -0
- package/dist/module/CallSettings/UcmBackendConnector.js +100 -0
- package/dist/module/CallSettings/WxCallBackendConnector.js +287 -0
- package/dist/module/CallSettings/constants.js +11 -0
- package/dist/module/CallSettings/testFixtures.js +62 -0
- package/dist/module/CallSettings/types.js +1 -0
- package/dist/module/CallingClient/CallingClient.js +268 -0
- package/dist/module/CallingClient/callRecordFixtures.js +93 -0
- package/dist/module/CallingClient/calling/CallerId/index.js +169 -0
- package/dist/module/CallingClient/calling/CallerId/types.js +1 -0
- package/dist/module/CallingClient/calling/call.js +1649 -0
- package/dist/module/CallingClient/calling/callManager.js +274 -0
- package/dist/module/CallingClient/calling/index.js +2 -0
- package/dist/module/CallingClient/calling/types.js +53 -0
- package/dist/module/CallingClient/callingClientFixtures.js +38 -0
- package/dist/module/CallingClient/constants.js +122 -0
- package/dist/module/CallingClient/line/index.js +110 -0
- package/dist/module/CallingClient/line/types.js +14 -0
- package/dist/module/CallingClient/registration/index.js +1 -0
- package/dist/module/CallingClient/registration/register.js +507 -0
- package/dist/module/CallingClient/registration/registerFixtures.js +28 -0
- package/dist/module/CallingClient/registration/types.js +1 -0
- package/dist/module/CallingClient/types.js +1 -0
- package/dist/module/Contacts/ContactsClient.js +487 -0
- package/dist/module/Contacts/constants.js +20 -0
- package/dist/module/Contacts/contactFixtures.js +284 -0
- package/dist/module/Contacts/types.js +10 -0
- package/dist/module/Errors/catalog/CallError.js +26 -0
- package/dist/module/Errors/catalog/CallingDeviceError.js +18 -0
- package/dist/module/Errors/catalog/ExtendedError.js +10 -0
- package/dist/module/Errors/catalog/LineError.js +24 -0
- package/dist/module/Errors/index.js +2 -0
- package/dist/module/Errors/types.js +48 -0
- package/dist/module/Events/impl/index.js +19 -0
- package/dist/module/Events/types.js +74 -0
- package/dist/module/Logger/index.js +114 -0
- package/dist/module/Logger/types.js +25 -0
- package/dist/module/Metrics/index.js +232 -0
- package/dist/module/Metrics/types.js +37 -0
- package/dist/module/SDKConnector/index.js +39 -0
- package/dist/module/SDKConnector/types.js +1 -0
- package/dist/module/SDKConnector/utils.js +12 -0
- package/dist/module/Voicemail/BroadworksBackendConnector.js +289 -0
- package/dist/module/Voicemail/UcmBackendConnector.js +275 -0
- package/dist/module/Voicemail/Voicemail.js +110 -0
- package/dist/module/Voicemail/WxCallBackendConnector.js +279 -0
- package/dist/module/Voicemail/constants.js +29 -0
- package/dist/module/Voicemail/types.js +1 -0
- package/dist/module/Voicemail/voicemailFixture.js +449 -0
- package/dist/module/common/Utils.js +802 -0
- package/dist/module/common/constants.js +40 -0
- package/dist/module/common/index.js +1 -0
- package/dist/module/common/testUtil.js +938 -0
- package/dist/module/common/types.js +57 -0
- package/dist/module/index.js +8 -0
- package/dist/types/CallHistory/CallHistory.d.ts +19 -0
- package/dist/types/CallHistory/CallHistory.d.ts.map +1 -0
- package/dist/types/CallHistory/callHistoryFixtures.d.ts +95 -0
- package/dist/types/CallHistory/callHistoryFixtures.d.ts.map +1 -0
- package/dist/types/CallHistory/constants.d.ts +10 -0
- package/dist/types/CallHistory/constants.d.ts.map +1 -0
- package/dist/types/CallHistory/types.d.ts +21 -0
- package/dist/types/CallHistory/types.d.ts.map +1 -0
- package/dist/types/CallSettings/CallSettings.d.ts +20 -0
- package/dist/types/CallSettings/CallSettings.d.ts.map +1 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts +20 -0
- package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -0
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts +22 -0
- package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -0
- package/dist/types/CallSettings/constants.d.ts +12 -0
- package/dist/types/CallSettings/constants.d.ts.map +1 -0
- package/dist/types/CallSettings/testFixtures.d.ts +16 -0
- package/dist/types/CallSettings/testFixtures.d.ts.map +1 -0
- package/dist/types/CallSettings/types.d.ts +108 -0
- package/dist/types/CallSettings/types.d.ts.map +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +38 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -0
- package/dist/types/CallingClient/callRecordFixtures.d.ts +4 -0
- package/dist/types/CallingClient/callRecordFixtures.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/CallerId/index.d.ts +18 -0
- package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/CallerId/types.d.ts +42 -0
- package/dist/types/CallingClient/calling/CallerId/types.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/call.d.ts +95 -0
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/callManager.d.ts +22 -0
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/index.d.ts +3 -0
- package/dist/types/CallingClient/calling/index.d.ts.map +1 -0
- package/dist/types/CallingClient/calling/types.d.ts +204 -0
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -0
- package/dist/types/CallingClient/callingClientFixtures.d.ts +19 -0
- package/dist/types/CallingClient/callingClientFixtures.d.ts.map +1 -0
- package/dist/types/CallingClient/constants.d.ts +123 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/line/index.d.ts +39 -0
- package/dist/types/CallingClient/line/index.d.ts.map +1 -0
- package/dist/types/CallingClient/line/types.d.ts +51 -0
- package/dist/types/CallingClient/line/types.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/index.d.ts +2 -0
- package/dist/types/CallingClient/registration/index.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/register.d.ts +65 -0
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/registerFixtures.d.ts +29 -0
- package/dist/types/CallingClient/registration/registerFixtures.d.ts.map +1 -0
- package/dist/types/CallingClient/registration/types.d.ts +21 -0
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -0
- package/dist/types/CallingClient/types.d.ts +30 -0
- package/dist/types/CallingClient/types.d.ts.map +1 -0
- package/dist/types/Contacts/ContactsClient.d.ts +28 -0
- package/dist/types/Contacts/ContactsClient.d.ts.map +1 -0
- package/dist/types/Contacts/constants.d.ts +20 -0
- package/dist/types/Contacts/constants.d.ts.map +1 -0
- package/dist/types/Contacts/contactFixtures.d.ts +281 -0
- package/dist/types/Contacts/contactFixtures.d.ts.map +1 -0
- package/dist/types/Contacts/types.d.ts +75 -0
- package/dist/types/Contacts/types.d.ts.map +1 -0
- package/dist/types/Errors/catalog/CallError.d.ts +12 -0
- package/dist/types/Errors/catalog/CallError.d.ts.map +1 -0
- package/dist/types/Errors/catalog/CallingDeviceError.d.ts +11 -0
- package/dist/types/Errors/catalog/CallingDeviceError.d.ts.map +1 -0
- package/dist/types/Errors/catalog/ExtendedError.d.ts +7 -0
- package/dist/types/Errors/catalog/ExtendedError.d.ts.map +1 -0
- package/dist/types/Errors/catalog/LineError.d.ts +11 -0
- package/dist/types/Errors/catalog/LineError.d.ts.map +1 -0
- package/dist/types/Errors/index.d.ts +3 -0
- package/dist/types/Errors/index.d.ts.map +1 -0
- package/dist/types/Errors/types.d.ts +61 -0
- package/dist/types/Errors/types.d.ts.map +1 -0
- package/dist/types/Events/impl/index.d.ts +9 -0
- package/dist/types/Events/impl/index.d.ts.map +1 -0
- package/dist/types/Events/types.d.ts +284 -0
- package/dist/types/Events/types.d.ts.map +1 -0
- package/dist/types/Logger/index.d.ts +13 -0
- package/dist/types/Logger/index.d.ts.map +1 -0
- package/dist/types/Logger/types.d.ts +26 -0
- package/dist/types/Logger/types.d.ts.map +1 -0
- package/dist/types/Metrics/index.d.ts +6 -0
- package/dist/types/Metrics/index.d.ts.map +1 -0
- package/dist/types/Metrics/types.d.ts +43 -0
- package/dist/types/Metrics/types.d.ts.map +1 -0
- package/dist/types/SDKConnector/index.d.ts +13 -0
- package/dist/types/SDKConnector/index.d.ts.map +1 -0
- package/dist/types/SDKConnector/types.d.ts +129 -0
- package/dist/types/SDKConnector/types.d.ts.map +1 -0
- package/dist/types/SDKConnector/utils.d.ts +6 -0
- package/dist/types/SDKConnector/utils.d.ts.map +1 -0
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts +28 -0
- package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -0
- package/dist/types/Voicemail/UcmBackendConnector.d.ts +35 -0
- package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -0
- package/dist/types/Voicemail/Voicemail.d.ts +28 -0
- package/dist/types/Voicemail/Voicemail.d.ts.map +1 -0
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts +24 -0
- package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -0
- package/dist/types/Voicemail/constants.d.ts +30 -0
- package/dist/types/Voicemail/constants.d.ts.map +1 -0
- package/dist/types/Voicemail/types.d.ts +134 -0
- package/dist/types/Voicemail/types.d.ts.map +1 -0
- package/dist/types/Voicemail/voicemailFixture.d.ts +350 -0
- package/dist/types/Voicemail/voicemailFixture.d.ts.map +1 -0
- package/dist/types/common/Utils.d.ts +35 -0
- package/dist/types/common/Utils.d.ts.map +1 -0
- package/dist/types/common/constants.d.ts +41 -0
- package/dist/types/common/constants.d.ts.map +1 -0
- package/dist/types/common/index.d.ts +2 -0
- package/dist/types/common/index.d.ts.map +1 -0
- package/dist/types/common/testUtil.d.ts +3612 -0
- package/dist/types/common/testUtil.d.ts.map +1 -0
- package/dist/types/common/types.d.ts +192 -0
- package/dist/types/common/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +161 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SessionType, Disposition, MOBIUS_EVENT_KEYS } from '../Events/types';
|
|
2
|
+
const WEBEX_CALL_SESSION = {
|
|
3
|
+
id: 'd74d19cc-6aa7-f341-6012-aec433cc6f8d',
|
|
4
|
+
durationSecs: 438,
|
|
5
|
+
self: {
|
|
6
|
+
id: 'a24027e7-9b6e-4047-a950-42f4492148ec',
|
|
7
|
+
name: 'Mark',
|
|
8
|
+
phoneNumber: '123456',
|
|
9
|
+
},
|
|
10
|
+
url: 'https://janus-a.wbx2.com/janus/api/v1/history/userSessions/d74d19cc-6aa7-f341-6012-aec433cc6f8d',
|
|
11
|
+
sessionId: 'd74d19cc-6aa7-f341-6012-aec433cc6f8d',
|
|
12
|
+
sessionType: SessionType.WEBEX_CALLING,
|
|
13
|
+
startTime: '2022-08-02T10:45:21.565Z',
|
|
14
|
+
endTime: '2022-08-02T10:53:01.624Z',
|
|
15
|
+
direction: 'OUTGOING',
|
|
16
|
+
disposition: Disposition.INITIATED,
|
|
17
|
+
other: {
|
|
18
|
+
id: 'c9bde63c-e3e2-4db4-ba45-0d6c698ffd65',
|
|
19
|
+
name: 'test',
|
|
20
|
+
isPrivate: false,
|
|
21
|
+
callbackAddress: 'c9bde63c-e3e2-4db4-ba45-0d6c698ffd65',
|
|
22
|
+
phoneNumber: '123456679',
|
|
23
|
+
},
|
|
24
|
+
durationSeconds: 438,
|
|
25
|
+
joinedDurationSeconds: 457,
|
|
26
|
+
participantCount: 2,
|
|
27
|
+
links: {
|
|
28
|
+
locusUrl: 'https://locus-a.wbx2.com/locus/api/v1/loci/f5dbe4da-663b-3f73-a2fc-3a2fb0f12080',
|
|
29
|
+
conversationUrl: 'https://conv-a.wbx2.com/conversation/api/v1/conversations/c9252ff0-9de2-11ec-a582-59d00c02cca9',
|
|
30
|
+
callbackAddress: '123-456-7890',
|
|
31
|
+
},
|
|
32
|
+
isDeleted: false,
|
|
33
|
+
isPMR: false,
|
|
34
|
+
correlationIds: ['58ea6cd9-852b-4a77-957f-e704c8b0e63e'],
|
|
35
|
+
};
|
|
36
|
+
const SPARK_CALL_SESSION = {
|
|
37
|
+
id: 'd74d19cc-6aa7-f341-6012-aec433cc6f8d',
|
|
38
|
+
durationSecs: 438,
|
|
39
|
+
self: {
|
|
40
|
+
id: 'a24027e7-9b6e-4047-a950-42f4492148ec',
|
|
41
|
+
name: 'Mark',
|
|
42
|
+
phoneNumber: '123456',
|
|
43
|
+
},
|
|
44
|
+
url: 'https://janus-a.wbx2.com/janus/api/v1/history/userSessions/d74d19cc-6aa7-f341-6012-aec433cc6f8d',
|
|
45
|
+
sessionId: 'd74d19cc-6aa7-f341-6012-aec433cc6f8d',
|
|
46
|
+
sessionType: SessionType.SPARK,
|
|
47
|
+
startTime: '2022-08-02T10:45:21.565Z',
|
|
48
|
+
endTime: '2022-08-02T10:53:01.624Z',
|
|
49
|
+
direction: 'OUTGOING',
|
|
50
|
+
disposition: Disposition.INITIATED,
|
|
51
|
+
other: {
|
|
52
|
+
id: 'c9bde63c-e3e2-4db4-ba45-0d6c698ffd65',
|
|
53
|
+
name: 'test',
|
|
54
|
+
isPrivate: false,
|
|
55
|
+
callbackAddress: 'c9bde63c-e3e2-4db4-ba45-0d6c698ffd65',
|
|
56
|
+
phoneNumber: '123456679',
|
|
57
|
+
},
|
|
58
|
+
durationSeconds: 438,
|
|
59
|
+
joinedDurationSeconds: 457,
|
|
60
|
+
participantCount: 2,
|
|
61
|
+
links: {
|
|
62
|
+
locusUrl: 'https://locus-a.wbx2.com/locus/api/v1/loci/f5dbe4da-663b-3f73-a2fc-3a2fb0f12080',
|
|
63
|
+
conversationUrl: 'https://conv-a.wbx2.com/conversation/api/v1/conversations/c9252ff0-9de2-11ec-a582-59d00c02cca9',
|
|
64
|
+
callbackAddress: '123-456-7890',
|
|
65
|
+
},
|
|
66
|
+
isDeleted: false,
|
|
67
|
+
isPMR: false,
|
|
68
|
+
correlationIds: ['58ea6cd9-852b-4a77-957f-e704c8b0e63e'],
|
|
69
|
+
};
|
|
70
|
+
export const MOCK_SESSION_EVENT = {
|
|
71
|
+
id: 'id',
|
|
72
|
+
data: {
|
|
73
|
+
userSessions: {
|
|
74
|
+
userSessions: [WEBEX_CALL_SESSION],
|
|
75
|
+
statusCode: 0,
|
|
76
|
+
},
|
|
77
|
+
eventType: MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE,
|
|
78
|
+
},
|
|
79
|
+
timestamp: 12345,
|
|
80
|
+
trackingId: 'tracking-id',
|
|
81
|
+
};
|
|
82
|
+
export const MOCK_MULTIPLE_SESSIONS_EVENT = {
|
|
83
|
+
id: 'id',
|
|
84
|
+
data: {
|
|
85
|
+
userSessions: {
|
|
86
|
+
userSessions: [WEBEX_CALL_SESSION, SPARK_CALL_SESSION],
|
|
87
|
+
statusCode: 0,
|
|
88
|
+
},
|
|
89
|
+
eventType: MOBIUS_EVENT_KEYS.CALL_SESSION_EVENT_INCLUSIVE,
|
|
90
|
+
},
|
|
91
|
+
timestamp: 12345,
|
|
92
|
+
trackingId: 'tracking-id',
|
|
93
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import log from '../../../Logger/index';
|
|
2
|
+
import { CALLER_ID_FILE, FETCH_NAME, VALID_PHONE } from '../../constants';
|
|
3
|
+
import SDKConnector from '../../../SDKConnector';
|
|
4
|
+
import { resolveCallerIdDisplay } from '../../../common';
|
|
5
|
+
export class CallerId {
|
|
6
|
+
webex;
|
|
7
|
+
callerInfo;
|
|
8
|
+
sdkConnector;
|
|
9
|
+
emitter;
|
|
10
|
+
constructor(webex, emitter) {
|
|
11
|
+
this.sdkConnector = SDKConnector;
|
|
12
|
+
this.callerInfo = {};
|
|
13
|
+
if (!this.sdkConnector.getWebex()) {
|
|
14
|
+
SDKConnector.setWebex(webex);
|
|
15
|
+
}
|
|
16
|
+
this.webex = this.sdkConnector.getWebex();
|
|
17
|
+
this.emitter = emitter;
|
|
18
|
+
}
|
|
19
|
+
async resolveCallerId(filter) {
|
|
20
|
+
const displayResult = (await resolveCallerIdDisplay(filter));
|
|
21
|
+
let isChanged = false;
|
|
22
|
+
if (displayResult.name && this.callerInfo.name !== displayResult.name) {
|
|
23
|
+
log.info('Updating Name after resolution', {
|
|
24
|
+
file: CALLER_ID_FILE,
|
|
25
|
+
method: 'resolveCallerId',
|
|
26
|
+
});
|
|
27
|
+
this.callerInfo.name = displayResult.name;
|
|
28
|
+
isChanged = true;
|
|
29
|
+
}
|
|
30
|
+
if (displayResult.num && this.callerInfo.num !== displayResult.num) {
|
|
31
|
+
log.info('Updating Number after resolution', {
|
|
32
|
+
file: CALLER_ID_FILE,
|
|
33
|
+
method: 'resolveCallerId',
|
|
34
|
+
});
|
|
35
|
+
this.callerInfo.num = displayResult.num;
|
|
36
|
+
isChanged = true;
|
|
37
|
+
}
|
|
38
|
+
if (!this.callerInfo.avatarSrc || this.callerInfo.avatarSrc !== displayResult.avatarSrc) {
|
|
39
|
+
log.info('Updating Avatar Id after resolution', {
|
|
40
|
+
file: CALLER_ID_FILE,
|
|
41
|
+
method: 'resolveCallerId',
|
|
42
|
+
});
|
|
43
|
+
this.callerInfo.avatarSrc = displayResult.avatarSrc;
|
|
44
|
+
isChanged = true;
|
|
45
|
+
}
|
|
46
|
+
if (!this.callerInfo.id || this.callerInfo.id !== displayResult.id) {
|
|
47
|
+
log.info('Updating User Id after resolution', {
|
|
48
|
+
file: CALLER_ID_FILE,
|
|
49
|
+
method: 'resolveCallerId',
|
|
50
|
+
});
|
|
51
|
+
this.callerInfo.id = displayResult.id;
|
|
52
|
+
isChanged = true;
|
|
53
|
+
}
|
|
54
|
+
if (isChanged) {
|
|
55
|
+
this.emitter(this.callerInfo);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async parseRemotePartyInfo(data) {
|
|
59
|
+
const lastToken = data.split(';').slice(-1)[0];
|
|
60
|
+
if (lastToken.includes('externalId')) {
|
|
61
|
+
const externalId = lastToken.split('=')[1];
|
|
62
|
+
log.info(`externalId retrieved: ${externalId}`, {
|
|
63
|
+
file: CALLER_ID_FILE,
|
|
64
|
+
method: 'parseRemotePartyInfo',
|
|
65
|
+
});
|
|
66
|
+
this.resolveCallerId(`id eq "${externalId}"`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
log.warn(`externalId not found!`, {
|
|
70
|
+
file: CALLER_ID_FILE,
|
|
71
|
+
method: 'parseRemotePartyInfo',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
parseSipUri(paid) {
|
|
76
|
+
const result = {};
|
|
77
|
+
const data = paid.split('@')[0].replace(/"/g, '');
|
|
78
|
+
const nameMatch = FETCH_NAME.exec(data);
|
|
79
|
+
const num = data.substring(data.indexOf(':') + 1, data.length);
|
|
80
|
+
if (nameMatch) {
|
|
81
|
+
result.name = nameMatch[0].trimEnd();
|
|
82
|
+
log.info(`Parsed Name: ${result.name}`, {
|
|
83
|
+
file: CALLER_ID_FILE,
|
|
84
|
+
method: 'parseSipUri',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
log.warn(`Name field not found!`, {
|
|
89
|
+
file: CALLER_ID_FILE,
|
|
90
|
+
method: 'parseSipUri',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const phoneMatch = num.match(VALID_PHONE);
|
|
94
|
+
if (phoneMatch && phoneMatch[0].length === num.length) {
|
|
95
|
+
result.num = num;
|
|
96
|
+
log.info(`Parsed Number: ${result.num}`, {
|
|
97
|
+
file: CALLER_ID_FILE,
|
|
98
|
+
method: 'parseSipUri',
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
log.warn(`Number field not found!`, {
|
|
103
|
+
file: CALLER_ID_FILE,
|
|
104
|
+
method: 'parseSipUri',
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
fetchCallerDetails(callerId) {
|
|
110
|
+
this.callerInfo.id = undefined;
|
|
111
|
+
this.callerInfo.avatarSrc = undefined;
|
|
112
|
+
this.callerInfo.name = undefined;
|
|
113
|
+
this.callerInfo.num = undefined;
|
|
114
|
+
if ('p-asserted-identity' in callerId) {
|
|
115
|
+
log.info(`Parsing p-asserted-identity:- ${callerId['p-asserted-identity']}`, {
|
|
116
|
+
file: CALLER_ID_FILE,
|
|
117
|
+
method: 'fetchCallerDetails',
|
|
118
|
+
});
|
|
119
|
+
const result = this.parseSipUri(callerId['p-asserted-identity']);
|
|
120
|
+
this.callerInfo.name = result.name;
|
|
121
|
+
this.callerInfo.num = result.num;
|
|
122
|
+
log.info(`CallerId retrieved from p-asserted-identity: name: ${this.callerInfo.name} , num: ${this.callerInfo.num}`, {
|
|
123
|
+
file: CALLER_ID_FILE,
|
|
124
|
+
method: 'fetchCallerDetails',
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (callerId.from) {
|
|
128
|
+
log.info(`Parsing from header:- ${callerId.from}`, {
|
|
129
|
+
file: CALLER_ID_FILE,
|
|
130
|
+
method: 'fetchCallerDetails',
|
|
131
|
+
});
|
|
132
|
+
const result = this.parseSipUri(callerId.from);
|
|
133
|
+
log.info(`CallerId retrieved from FROM: name: ${result.name} , num: ${result.num}`, {
|
|
134
|
+
file: CALLER_ID_FILE,
|
|
135
|
+
method: 'fetchCallerDetails',
|
|
136
|
+
});
|
|
137
|
+
if (!this.callerInfo.name && result.name) {
|
|
138
|
+
log.info('Updating name field from From header', {
|
|
139
|
+
file: CALLER_ID_FILE,
|
|
140
|
+
method: 'fetchCallerDetails',
|
|
141
|
+
});
|
|
142
|
+
this.callerInfo.name = result.name;
|
|
143
|
+
}
|
|
144
|
+
if (!this.callerInfo.num && result.num) {
|
|
145
|
+
log.info('Updating number field from From header', {
|
|
146
|
+
file: CALLER_ID_FILE,
|
|
147
|
+
method: 'fetchCallerDetails',
|
|
148
|
+
});
|
|
149
|
+
this.callerInfo.num = result.num;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (this.callerInfo.name || this.callerInfo.num) {
|
|
153
|
+
this.emitter(this.callerInfo);
|
|
154
|
+
}
|
|
155
|
+
if ('x-broadworks-remote-party-info' in callerId) {
|
|
156
|
+
log.info(`Parsing x-broadworks-remote-party-info:- ${callerId['x-broadworks-remote-party-info']}`, {
|
|
157
|
+
file: CALLER_ID_FILE,
|
|
158
|
+
method: 'fetchCallerDetails',
|
|
159
|
+
});
|
|
160
|
+
this.parseRemotePartyInfo(callerId['x-broadworks-remote-party-info']);
|
|
161
|
+
}
|
|
162
|
+
log.log(`Intermediate callerId :- name: ${this.callerInfo.name} , num: ${this.callerInfo.num}`, {
|
|
163
|
+
file: CALLER_ID_FILE,
|
|
164
|
+
method: 'fetchCallerDetails',
|
|
165
|
+
});
|
|
166
|
+
return this.callerInfo;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export const createCallerId = (webex, emitterCb) => new CallerId(webex, emitterCb);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|