Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export default class ControlsOptionsManager {
*/
private locusUrl: string;

/**
* @instance
* @type {string}
* @private
* @memberof ControlsOptionsManager
*/
private mainLocusUrl: string;

/**
* @param {MeetingRequest} request
* @param {Object} options
Expand Down Expand Up @@ -87,12 +95,16 @@ export default class ControlsOptionsManager {

/**
* @param {string} url
* @param {boolean} isMainLocus
* @returns {void}
* @public
* @memberof ControlsOptionsManager
*/
public setLocusUrl(url: string) {
public setLocusUrl(url: string, isMainLocus?: boolean) {
this.locusUrl = url;
if (isMainLocus) {
this.mainLocusUrl = url;
}
}

/**
Expand Down Expand Up @@ -160,11 +172,16 @@ export default class ControlsOptionsManager {
});

return payloads.reduce((previous, payload) => {
const extraBody =
this.mainLocusUrl && this.mainLocusUrl !== this.locusUrl
? {authorizingLocusUrl: this.locusUrl}
: {};

return previous.then(() =>
// @ts-ignore
this.request.request({
uri: `${this.locusUrl}/${CONTROLS}`,
body: payload,
uri: `${this.mainLocusUrl || this.locusUrl}/${CONTROLS}`,
body: {...payload, ...extraBody},
method: HTTP_VERBS.PATCH,
})
);
Expand Down Expand Up @@ -241,11 +258,15 @@ export default class ControlsOptionsManager {
if (error) {
return Promise.reject(error);
}
const extraBody =
this.mainLocusUrl && this.mainLocusUrl !== this.locusUrl
? {authorizingLocusUrl: this.locusUrl}
: {};

// @ts-ignore
return this.request.request({
uri: `${this.locusUrl}/${CONTROLS}`,
body,
uri: `${this.mainLocusUrl || this.locusUrl}/${CONTROLS}`,
body: {...body, ...extraBody},
method: HTTP_VERBS.PATCH,
});
}
Expand Down
9 changes: 5 additions & 4 deletions packages/@webex/plugin-meetings/src/locus-info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export default class LocusInfo extends EventsScope {
// For 1:1 space meeting the conversation Url does not exist in locus.conversation
this.updateConversationUrl(locus.conversationUrl, locus.info);
this.updateControls(locus.controls, locus.self);
this.updateLocusUrl(locus.url);
this.updateLocusUrl(locus.url, ControlsUtils.isMainSessionDTO(locus));
this.updateFullState(locus.fullState);
this.updateMeetingInfo(locus.info);
this.updateEmbeddedApps(locus.embeddedApps);
Expand Down Expand Up @@ -549,7 +549,7 @@ export default class LocusInfo extends EventsScope {
this.updateCreated(locus.created);
this.updateFullState(locus.fullState);
this.updateHostInfo(locus.host);
this.updateLocusUrl(locus.url);
this.updateLocusUrl(locus.url, ControlsUtils.isMainSessionDTO(locus));
this.updateMeetingInfo(locus.info, locus.self);
this.updateMediaShares(locus.mediaShares);
this.updateParticipantsUrl(locus.participantsUrl);
Expand Down Expand Up @@ -1732,10 +1732,11 @@ export default class LocusInfo extends EventsScope {
/**
* handles when the locus.url is updated
* @param {String} url
* @param {Boolean} isMainLocus
* @returns {undefined}
* emits internal event locus_info_update_url
*/
updateLocusUrl(url: string) {
updateLocusUrl(url: string, isMainLocus = true) {
if (url && this.url !== url) {
this.url = url;
this.updateMeeting({locusUrl: url});
Expand All @@ -1745,7 +1746,7 @@ export default class LocusInfo extends EventsScope {
function: 'updateLocusUrl',
},
EVENTS.LOCUS_INFO_UPDATE_URL,
url
{url, isMainLocus}
);
}
}
Expand Down
44 changes: 24 additions & 20 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3356,27 +3356,31 @@ export default class Meeting extends StatelessWebexPlugin {
* @memberof Meeting
*/
private setUpLocusUrlListener() {
this.locusInfo.on(EVENTS.LOCUS_INFO_UPDATE_URL, (payload) => {
this.members.locusUrlUpdate(payload);
this.breakouts.locusUrlUpdate(payload);
this.simultaneousInterpretation.locusUrlUpdate(payload);
this.annotation.locusUrlUpdate(payload);
this.locusUrl = payload;
this.locusId = this.locusUrl?.split('/').pop();
this.recordingController.setLocusUrl(this.locusUrl);
this.controlsOptionsManager.setLocusUrl(this.locusUrl);
this.webinar.locusUrlUpdate(payload);
this.locusInfo.on(
EVENTS.LOCUS_INFO_UPDATE_URL,
(payload: {url: string; isMainLocus?: boolean}) => {
const {url, isMainLocus} = payload;
this.members.locusUrlUpdate(url);
this.breakouts.locusUrlUpdate(url);
this.simultaneousInterpretation.locusUrlUpdate(url);
this.annotation.locusUrlUpdate(url);
this.locusUrl = url;
this.locusId = this.locusUrl?.split('/').pop();
this.recordingController.setLocusUrl(this.locusUrl);
this.controlsOptionsManager.setLocusUrl(this.locusUrl, !!isMainLocus);
this.webinar.locusUrlUpdate(url);

Trigger.trigger(
this,
{
file: 'meeting/index',
function: 'setUpLocusSelfListener',
},
EVENT_TRIGGERS.MEETING_LOCUS_URL_UPDATE,
{locusUrl: payload}
);
});
Trigger.trigger(
this,
{
file: 'meeting/index',
function: 'setUpLocusSelfListener',
},
EVENT_TRIGGERS.MEETING_LOCUS_URL_UPDATE,
{locusUrl: url}
);
}
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ describe('plugin-meetings', () => {

manager.set({
locusUrl: 'test/id',
mainLocusUrl: '',
displayHints: [],
});
});
Expand Down Expand Up @@ -201,6 +202,38 @@ describe('plugin-meetings', () => {
Util.canUpdate = restorable;
});
});

it('should call request with mainLocusUrl and locusUrl as authorizingLocusUrl if mainLocusUrl is exist and not same with locusUrl', () => {
const restorable = Util.canUpdate;
Util.canUpdate = sinon.stub().returns(true);
manager.mainLocusUrl = 'test/main';

const audio = {scope: 'audio', properties: {a: 1, b: 2}};
const reactions = {scope: 'reactions', properties: {c: 3, d: 4}};

return manager.update(audio, reactions)
.then(() => {
assert.calledWith(request.request, {
uri: 'test/main/controls',
body: {
audio: audio.properties,
authorizingLocusUrl: 'test/id'
},
method: HTTP_VERBS.PATCH,
});

assert.calledWith(request.request, {
uri: 'test/main/controls',
body: {
reactions: reactions.properties,
authorizingLocusUrl: 'test/id'
},
method: HTTP_VERBS.PATCH,
});

Util.canUpdate = restorable;
});
});
});

describe('Mute/Unmute All', () => {
Expand All @@ -214,6 +247,7 @@ describe('plugin-meetings', () => {

manager.set({
locusUrl: 'test/id',
mainLocusUrl: '',
displayHints: [],
})
});
Expand Down Expand Up @@ -305,6 +339,19 @@ describe('plugin-meetings', () => {

assert.deepEqual(result, request.request.firstCall.returnValue);
});

it('request with mainLocusUrl and make locusUrl as authorizingLocusUrl if mainLocusUrl is exist and not same with locusUrl', () => {
manager.setDisplayHints(['MUTE_ALL', 'DISABLE_HARD_MUTE', 'DISABLE_MUTE_ON_ENTRY']);
manager.mainLocusUrl = `test/main`;

const result = manager.setMuteAll(true, true, true, ['attendee']);

assert.calledWith(request.request, { uri: 'test/main/controls',
body: { audio: { muted: true, disallowUnmute: true, muteOnEntry: true, roles: ['attendee'] }, authorizingLocusUrl: 'test/id' },
method: HTTP_VERBS.PATCH});

assert.deepEqual(result, request.request.firstCall.returnValue);
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,45 @@ describe('plugin-meetings', () => {
});
});

describe('#updateLocusUrl', () => {
it('trigger LOCUS_INFO_UPDATE_URL event with isMainLocus is true as default', () => {
const fakeUrl = "https://fake.com/locus";
locusInfo.emitScoped = sinon.stub();
locusInfo.updateLocusUrl(fakeUrl);

assert.calledWith(
locusInfo.emitScoped,
{
file: 'locus-info',
function: 'updateLocusUrl',
},
EVENTS.LOCUS_INFO_UPDATE_URL,
{
url: fakeUrl,
isMainLocus: true
},
);
});
it('trigger LOCUS_INFO_UPDATE_URL event with isMainLocus is false', () => {
const fakeUrl = "https://fake.com/locus";
locusInfo.emitScoped = sinon.stub();
locusInfo.updateLocusUrl(fakeUrl, false);

assert.calledWith(
locusInfo.emitScoped,
{
file: 'locus-info',
function: 'updateLocusUrl',
},
EVENTS.LOCUS_INFO_UPDATE_URL,
{
url: fakeUrl,
isMainLocus: false
},
);
});
});

// semi-integration tests that use real LocusInfo with real Parser
// and test various scenarios related to handling out-of-order Locus delta events
describe('handling of out-of-order Locus delta events', () => {
Expand Down
21 changes: 19 additions & 2 deletions packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10550,6 +10550,7 @@ describe('plugin-meetings', () => {
describe('#setUpLocusUrlListener', () => {
it('listens to the locus url update event', (done) => {
const newLocusUrl = 'newLocusUrl/12345';
const payload = {url: newLocusUrl}

meeting.members = {locusUrlUpdate: sinon.stub().returns(Promise.resolve(test1))};
meeting.recordingController = {setLocusUrl: sinon.stub().returns(undefined)};
Expand All @@ -10563,14 +10564,14 @@ describe('plugin-meetings', () => {
meeting.locusInfo.emit(
{function: 'test', file: 'test'},
'LOCUS_INFO_UPDATE_URL',
newLocusUrl
payload
);
assert.calledWith(meeting.members.locusUrlUpdate, newLocusUrl);
assert.calledOnceWithExactly(meeting.breakouts.locusUrlUpdate, newLocusUrl);
assert.calledOnceWithExactly(meeting.annotation.locusUrlUpdate, newLocusUrl);
assert.calledWith(meeting.members.locusUrlUpdate, newLocusUrl);
assert.calledWith(meeting.recordingController.setLocusUrl, newLocusUrl);
assert.calledWith(meeting.controlsOptionsManager.setLocusUrl, newLocusUrl);
assert.calledWith(meeting.controlsOptionsManager.setLocusUrl, newLocusUrl, false);
assert.calledWith(meeting.simultaneousInterpretation.locusUrlUpdate, newLocusUrl);
assert.calledWith(meeting.webinar.locusUrlUpdate, newLocusUrl);
assert.equal(meeting.locusUrl, newLocusUrl);
Expand All @@ -10588,6 +10589,22 @@ describe('plugin-meetings', () => {
{locusUrl: 'newLocusUrl/12345'}
);

done();
});
it('update mainLocusUrl for controlsOptionManager if payload.isMainLocus as true', (done) => {
const newLocusUrl = 'newLocusUrl/12345';
const payload = {url: newLocusUrl, isMainLocus: true}

meeting.controlsOptionsManager = {setLocusUrl: sinon.stub().returns(undefined)};

meeting.locusInfo.emit(
{function: 'test', file: 'test'},
'LOCUS_INFO_UPDATE_URL',
payload
);

assert.calledWith(meeting.controlsOptionsManager.setLocusUrl, newLocusUrl, true);

done();
});
});
Expand Down
Loading