diff --git a/docs/samples/browser-plugin-meetings/app.js b/docs/samples/browser-plugin-meetings/app.js index e0d39168d4d..f7ea76c1610 100644 --- a/docs/samples/browser-plugin-meetings/app.js +++ b/docs/samples/browser-plugin-meetings/app.js @@ -175,7 +175,7 @@ function register() { unregisterElm.disabled = true; registrationStatusElm.innerText = 'Registering...'; - webex.meetings.register(isGuest) + webex.meetings.register() .then(() => { console.log('Authentication#register() :: successfully registered'); toggleUnifiedMeetings.removeAttribute('disabled'); @@ -226,7 +226,6 @@ function unregister() { }); } -let isGuest = false; async function getGuestAccessToken() { await axios({ @@ -238,7 +237,6 @@ async function getGuestAccessToken() { }).then(function (response) { console.log("guest token response", response.data.body.token); tokenElm.value = response.data.body.token - isGuest = true; }).catch((e) =>{ console.error("Error fetching guest", e) }) diff --git a/packages/@webex/plugin-meetings/src/meetings/index.ts b/packages/@webex/plugin-meetings/src/meetings/index.ts index 7880f55b00f..efa2e9bee07 100644 --- a/packages/@webex/plugin-meetings/src/meetings/index.ts +++ b/packages/@webex/plugin-meetings/src/meetings/index.ts @@ -526,9 +526,8 @@ export default class Meetings extends WebexPlugin { * @returns {Promise} * @public * @memberof Meetings - * @param {boolean} isGuest */ - public register(isGuest) { + public register() { // @ts-ignore if (!this.webex.canAuthorize) { LoggerProxy.logger.error( @@ -546,16 +545,8 @@ export default class Meetings extends WebexPlugin { return Promise.resolve(); } - const promises = []; - // Only call fetchUserPreferredWebexSite() if not a guest - if (!isGuest) { - promises.push(this.fetchUserPreferredWebexSite()); - } else { - LoggerProxy.logger.info( - 'Meetings:index#register --> INFO, Skipping fetchUserPreferredWebexSite() because user is a guest' - ); - } - promises.push( + return Promise.all([ + this.fetchUserPreferredWebexSite(), this.getGeoHint(), this.startReachability().catch((error) => { LoggerProxy.logger.error(`Meetings:index#register --> GDM error, ${error.message}`); @@ -572,10 +563,8 @@ export default class Meetings extends WebexPlugin { ) // @ts-ignore .then(() => this.webex.internal.mercury.connect()), - MeetingsUtil.checkH264Support.call(this) - ); - - return Promise.all(promises) + MeetingsUtil.checkH264Support.call(this), + ]) .then(() => { this.listenForEvents(); Trigger.trigger( @@ -772,10 +761,18 @@ export default class Meetings extends WebexPlugin { * @memberof Meetings */ fetchUserPreferredWebexSite() { - return this.request.getMeetingPreferences().then((res) => { - if (res) { - this.preferredWebexSite = MeetingsUtil.parseDefaultSiteFromMeetingPreferences(res); + // @ts-ignore + return this.webex.people._getMe().then((me) => { + const Guest = me.type === 'appuser'; + if (!Guest) { + return this.request.getMeetingPreferences().then((res) => { + if (res) { + this.preferredWebexSite = MeetingsUtil.parseDefaultSiteFromMeetingPreferences(res); + } + }); } + + return Promise.resolve(); }); } diff --git a/packages/@webex/plugin-meetings/test/unit/spec/meetings/index.js b/packages/@webex/plugin-meetings/test/unit/spec/meetings/index.js index d2d42771657..b002643e139 100644 --- a/packages/@webex/plugin-meetings/test/unit/spec/meetings/index.js +++ b/packages/@webex/plugin-meetings/test/unit/spec/meetings/index.js @@ -101,6 +101,11 @@ describe('plugin-meetings', () => { Object.assign(webex, { logger, + people: { + _getMe: sinon.stub().resolves({ + type: 'validuser', + }), + } }); Object.assign(webex.meetings, { @@ -1276,6 +1281,21 @@ describe('plugin-meetings', () => { assert.equal(webex.meetings.preferredWebexSite, 'go.webex.com'); }); + const setup = ({me = {type: 'validuser'}} = {}) => { + Object.assign(webex.people,{ + _getMe: sinon.stub().returns(Promise.resolve(me)), + }) + } + + it('should not call request.getMeetingPreferences if user is a guest', async () => { + setup({me: {type: 'appuser'}}); + + await webex.meetings.fetchUserPreferredWebexSite(); + + assert.equal(webex.meetings.preferredWebexSite, ''); + assert.notCalled(webex.internal.services.getMeetingPreferences); + }); + it('should not fail if UserPreferred info is not fetched ', async () => { Object.assign(webex.internal, { services: {