Skip to content

Commit 985a6bb

Browse files
Address PR comments
Make new code in `proxyStreamingClientEvents` safer and use existing helper functions.
1 parent f49d19e commit 985a6bb

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

react-demo-app/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client-private.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { GenesysCloudWebrtcSdk } from './client';
44
import { SessionManager } from './sessions/session-manager';
55
import { SubscriptionEvent } from './types/interfaces';
66
import { ConversationUpdate } from './conversations/conversation-update';
7+
import { isAgentVideoJid } from "./utils";
78

89
/**
910
* Establish the connection with the streaming client.
@@ -93,11 +94,11 @@ export async function proxyStreamingClientEvents (this: GenesysCloudWebrtcSdk):
9394

9495
if (this._personDetails) {
9596
if (this.isJwtAuth) {
96-
const id = this._customerData.conversation?.id;
97-
const userId = this._personDetails.id;
97+
const convId = this._customerData.conversation?.id;
98+
const isGuest = !this._personDetails?.id;
9899
const roomJid = this._personDetails.chat?.jabberId;
99-
if (id && !userId && roomJid?.startsWith('agent-')) {
100-
this._streamingConnection.on(`notify:v2.guest.conversations.${id}`, (conversationEvent) => {
100+
if (convId && isGuest && isAgentVideoJid(roomJid)) {
101+
this._streamingConnection.on(`notify:v2.guest.conversations.${convId}`, (conversationEvent) => {
101102
handleConversationUpdate.call(this, conversationEvent);
102103
});
103104
}

test/unit/client-private.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe('proxyStreamingClientEvents', () => {
266266
expect(mockSdk._customerData).toBe(undefined);
267267
});
268268

269-
async function createEventDataAndCallProxyFunction(options = {} as any) {
269+
async function createEventDataAndCallProxyFunction(options = {} as { userId?: string, jabberId?: string, conversationId?: string, isJwtAuth?: boolean }) {
270270
const userId = 'userId' in options ? options.userId : undefined;
271271
const jabberId = 'jabberId' in options ? options.jabberId : 'agent-123@conference.com';
272272
const conversationId = 'conversationId' in options ? options.conversationId : 'conv123';

0 commit comments

Comments
 (0)