diff --git a/packages/ringcentral-integration/modules/CallMonitor/callMonitorHelper.js b/packages/ringcentral-integration/modules/CallMonitor/callMonitorHelper.js index 1dfbe07490..5853718ade 100644 --- a/packages/ringcentral-integration/modules/CallMonitor/callMonitorHelper.js +++ b/packages/ringcentral-integration/modules/CallMonitor/callMonitorHelper.js @@ -15,6 +15,20 @@ export function matchWephoneSessionWithAcitveCall(sessions, callItem) { return undefined; } const matches = sessions.filter((session) => { + // Strategy 1: use `P-Rc-Api-Ids` header of a webRTC session to match with `telephonySessionId` + // and `partyId` of a call data from presence api. + if (session.partyData && callItem.telephonySessionId) { + const { sessionId } = session.partyData; + if (sessionId === callItem.telephonySessionId) { + return true; + } + return false; + } + + // Strategy 2: use `call-id` header of a webRTC session to match with + // `id` of a call data from presence api. + // This approach is unstable since the `id` of a call data from presence api can change before + // the call being accepted. if (session.callId === callItem.id) { return true; } @@ -24,6 +38,7 @@ export function matchWephoneSessionWithAcitveCall(sessions, callItem) { } /** + * Strategy 3: * Hack: for conference call, the `to` field is Conference, * and the callItem's id won't change. According to `sip.js/src/session.js` * the `InviteClientContext`'s id will always begin with callItem's id. diff --git a/packages/ringcentral-integration/modules/Webphone/webphoneHelper.js b/packages/ringcentral-integration/modules/Webphone/webphoneHelper.js index 352fad7e22..7bd8770fc8 100644 --- a/packages/ringcentral-integration/modules/Webphone/webphoneHelper.js +++ b/packages/ringcentral-integration/modules/Webphone/webphoneHelper.js @@ -28,6 +28,11 @@ export function extractHeadersData(session, headers) { * "partyId": String, * "sessionId": String * } + * + * INFO: partyId is ID of the participant in current Session. Mostly it represents User on the call, + * it could be active participant (talking right now) or already disconnected User, + * e.g. who made a transfer to another person. + * To identify the User who owns the party you need to find owner.extensionId within party. */ const data = headers['P-Rc-Api-Ids'][0].raw .split(';')