From dbece2b1acfa07a5127e7c1853c5d5ca362cd101 Mon Sep 17 00:00:00 2001 From: Marcin Wojtczak Date: Mon, 2 Dec 2024 15:22:15 +0000 Subject: [PATCH] fix: ai pr comments --- .../plugin-meetings/src/meeting/util.ts | 25 ++++++++++--- .../plugin-meetings/src/roap/request.ts | 30 ++++++++++----- .../test/unit/spec/meeting/utils.js | 23 ++++++++++++ .../test/unit/spec/roap/request.ts | 37 ++++++++++++++++++- 4 files changed, 99 insertions(+), 16 deletions(-) diff --git a/packages/@webex/plugin-meetings/src/meeting/util.ts b/packages/@webex/plugin-meetings/src/meeting/util.ts index d88de6de931..b361b03366a 100644 --- a/packages/@webex/plugin-meetings/src/meeting/util.ts +++ b/packages/@webex/plugin-meetings/src/meeting/util.ts @@ -127,11 +127,26 @@ const MeetingUtil = { options: {meetingId: meeting.id}, }); - const reachability = await webex.meetings.reachability.getReachabilityReportToAttachToRoap(); - const clientMediaPreferences = await webex.meetings.reachability.getClientMediaPreferences( - meeting.isMultistream, - MeetingUtil.getIpVersion(webex) - ); + let reachability; + let clientMediaPreferences = { + // bare minimum fallback value that should allow us to join + ipver: IP_VERSION.unknown, + joinCookie: undefined, + preferTranscoding: !meeting.isMultistream, + }; + + try { + clientMediaPreferences = await webex.meetings.reachability.getClientMediaPreferences( + meeting.isMultistream, + MeetingUtil.getIpVersion(webex) + ); + reachability = await webex.meetings.reachability.getReachabilityReportToAttachToRoap(); + } catch (e) { + LoggerProxy.logger.error( + 'Meeting:util#joinMeeting --> Error getting reachability or clientMediaPreferences:', + e + ); + } // eslint-disable-next-line no-warning-comments // TODO: check if the meeting is in JOINING state diff --git a/packages/@webex/plugin-meetings/src/roap/request.ts b/packages/@webex/plugin-meetings/src/roap/request.ts index 06e0e97fea9..fc1dc5589f5 100644 --- a/packages/@webex/plugin-meetings/src/roap/request.ts +++ b/packages/@webex/plugin-meetings/src/roap/request.ts @@ -5,6 +5,7 @@ import LoggerProxy from '../common/logs/logger-proxy'; import {IP_VERSION, REACHABILITY} from '../constants'; import {LocusMediaRequest} from '../meeting/locusMediaRequest'; import MeetingUtil from '../meeting/util'; +import {ClientMediaPreferences} from '../reachability/reachability.types'; /** * @class RoapRequest @@ -41,17 +42,28 @@ export default class RoapRequest extends StatelessWebexPlugin { return Promise.reject(new Error('sendRoap called when locusMediaRequest is undefined')); } - const reachability = - // @ts-ignore - await this.webex.meetings.reachability.getReachabilityReportToAttachToRoap(); + let reachability; + let clientMediaPreferences: ClientMediaPreferences = { + // bare minimum fallback value that should allow us to join; + joinCookie: undefined, + ipver: IP_VERSION.unknown, + preferTranscoding: !isMultistream, + }; - const clientMediaPreferences = - // @ts-ignore - await this.webex.meetings.reachability.getClientMediaPreferences( - isMultistream, + try { + clientMediaPreferences = // @ts-ignore - MeetingUtil.getIpVersion(this.webex) - ); + await this.webex.meetings.reachability.getClientMediaPreferences( + isMultistream, + // @ts-ignore + MeetingUtil.getIpVersion(this.webex) + ); + reachability = + // @ts-ignore + await this.webex.meetings.reachability.getReachabilityReportToAttachToRoap(); + } catch (error) { + LoggerProxy.logger.error('Roap:request#sendRoap --> reachability error:', error); + } LoggerProxy.logger.info( `Roap:request#sendRoap --> ${roapMessage.messageType} seq:${roapMessage.seq} ${ diff --git a/packages/@webex/plugin-meetings/test/unit/spec/meeting/utils.js b/packages/@webex/plugin-meetings/test/unit/spec/meeting/utils.js index d61dc4ecf2d..2c2059a4d16 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/meeting/utils.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/meeting/utils.js @@ -473,6 +473,29 @@ describe('plugin-meetings', () => { }); }); + it('should handle failed reachability report retrieval', async () => { + webex.meetings.reachability.getReachabilityReportToAttachToRoap.rejects( + new Error('fake error') + ); + await MeetingUtil.joinMeeting(meeting, {}); + // Verify meeting join still proceeds + assert.calledOnce(meeting.meetingRequest.joinMeeting); + }); + + it('should handle failed clientMediaPreferences retrieval', async () => { + webex.meetings.reachability.getClientMediaPreferences.rejects(new Error('fake error')); + meeting.isMultistream = true; + await MeetingUtil.joinMeeting(meeting, {}); + // Verify meeting join still proceeds + assert.calledOnce(meeting.meetingRequest.joinMeeting); + const parameter = meeting.meetingRequest.joinMeeting.getCall(0).args[0]; + assert.deepEqual(parameter.clientMediaPreferences, { + preferTranscoding: false, + ipver: 0, + joinCookie: undefined, + }); + }); + it('#Should call meetingRequest.joinMeeting with breakoutsSupported=true when passed in as true', async () => { await MeetingUtil.joinMeeting(meeting, { breakoutsSupported: true, diff --git a/packages/@webex/plugin-meetings/test/unit/spec/roap/request.ts b/packages/@webex/plugin-meetings/test/unit/spec/roap/request.ts index 2f8a81de7d1..ace38ba8a17 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/roap/request.ts +++ b/packages/@webex/plugin-meetings/test/unit/spec/roap/request.ts @@ -82,12 +82,14 @@ describe('plugin-meetings/roap', () => { ); }); + afterEach(() => { + sinon.restore(); + }) + describe('sendRoap', () => { it('includes clientMediaPreferences and reachability in the request correctly', async () => { const locusMediaRequest = {send: sinon.stub().resolves({body: {locus: {}}})}; - const ipVersion = IP_VERSION.unknown; - const FAKE_REACHABILITY_REPORT = { id: 'fake reachability report', }; @@ -124,5 +126,36 @@ describe('plugin-meetings/roap', () => { reachability: FAKE_REACHABILITY_REPORT, }); }); + + it('includes default clientMediaPreferences if calls to reachability fail', async () => { + const locusMediaRequest = {send: sinon.stub().resolves({body: {locus: {}}})}; + + webex.meetings.reachability.getClientMediaPreferences.rejects(new Error('fake error')); + + await roapRequest.sendRoap({ + locusSelfUrl: locusUrl, + mediaId: 'mediaId', + roapMessage: { + seq: 'seq', + }, + meetingId: 'meeting-id', + isMultistream: true, + locusMediaRequest, + }); + + assert.calledOnce(webex.meetings.reachability.getClientMediaPreferences); + + const requestParams = locusMediaRequest.send.getCall(0).args[0]; + assert.deepEqual(requestParams, { + type: 'RoapMessage', + selfUrl: locusUrl, + clientMediaPreferences: {ipver: 0, joinCookie: undefined, preferTranscoding: false}, + mediaId: 'mediaId', + roapMessage: { + seq: 'seq', + }, + reachability: undefined, + }); + }); }); });