Skip to content

Commit 6436f50

Browse files
committed
[STREAM-978] - Filter out conversation events from voicemail users.
1 parent 8fd9421 commit 6436f50

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

src/sessions/softphone-session-handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ export class SoftphoneSessionHandler extends BaseSessionHandler {
500500
return;
501501
}
502502

503-
const participantsForUser = update.participants.filter(p => p.userId === this.sdk._personDetails.id).reverse();
503+
// Filter out voicemail participants - user ID can appear multiple times with different purposes.
504+
const participantsForUser = update.participants.filter((p) => p.userId === this.sdk._personDetails.id && p.purpose !== 'voicemail').reverse();
504505
let participant: IConversationParticipantFromEvent;
505506

506507
if (!participantsForUser.length) {

test/unit/sessions/softphone-session-handler.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,39 @@ describe('getUserParticipantFromConversationEvent()', () => {
18881888
it('should return the most recent participant if there are no calls on any of them', () => {
18891889
expect(handler.getUserParticipantFromConversationEvent(converversationUpdate)).toEqual(participant2);
18901890
});
1891+
1892+
it('should filter out voicemail participants and only return non-voicemail participants', () => {
1893+
const userParticipant: IConversationParticipantFromEvent = {
1894+
id: '3a843139-760b-41d8-8ac1-723ac2381280',
1895+
purpose: 'user',
1896+
userId,
1897+
videos: [],
1898+
calls: [{ ...call, state: CommunicationStates.connected }]
1899+
};
1900+
1901+
const voicemailParticipant: IConversationParticipantFromEvent = {
1902+
id: '3a843140-760b-41d8-8ac1-723ac2381290',
1903+
purpose: 'voicemail',
1904+
userId,
1905+
videos: [],
1906+
calls: []
1907+
};
1908+
1909+
const externalParticipant: IConversationParticipantFromEvent = {
1910+
id: 'dcec146d-52f2-4593-874d-d13f1bc3183d',
1911+
purpose: 'external',
1912+
userId: '1234',
1913+
videos: [],
1914+
calls: [{ ...call, state: CommunicationStates.connected }]
1915+
};
1916+
1917+
converversationUpdate.participants = [externalParticipant, userParticipant, voicemailParticipant];
1918+
1919+
const result = handler.getUserParticipantFromConversationEvent(converversationUpdate);
1920+
expect(result).toEqual(userParticipant);
1921+
expect(result?.purpose).toBe('user');
1922+
expect(result?.id).toBe('3a843139-760b-41d8-8ac1-723ac2381280');
1923+
});
18911924
});
18921925

18931926
describe('getCallStateFromParticipant()', () => {

0 commit comments

Comments
 (0)