Skip to content

Commit

Permalink
fix: ai pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-bazyl committed Dec 2, 2024
1 parent 14861b0 commit dbece2b
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 16 deletions.
25 changes: 20 additions & 5 deletions packages/@webex/plugin-meetings/src/meeting/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 21 additions & 9 deletions packages/@webex/plugin-meetings/src/roap/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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} ${
Expand Down
23 changes: 23 additions & 0 deletions packages/@webex/plugin-meetings/test/unit/spec/meeting/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
37 changes: 35 additions & 2 deletions packages/@webex/plugin-meetings/test/unit/spec/roap/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
Expand Down Expand Up @@ -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,
});
});
});
});

0 comments on commit dbece2b

Please sign in to comment.