From baa6d8a29430348ace9a5e67d19468d6c6a2d51b Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Fri, 4 Sep 2020 12:42:46 +0300 Subject: [PATCH] Correctly template in Jitsi widget auth if such exists Also add roomId to the widget data and URL template. It's needed by the Element Web Jitsi code to produce auth for the Jitsi backend. --- src/CallHandler.js | 4 ++-- src/components/views/elements/AppTile.js | 11 +++++++++-- src/utils/WidgetUtils.js | 11 ++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 702613bb81..3c7e7fcc78 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -405,13 +405,12 @@ async function _startCallApp(roomId, type) { confId = `JitsiConference${generateHumanReadableId()}`; } - let widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl(); + let widgetUrl = WidgetUtils.getLocalJitsiWrapperUrl({auth: jitsiAuth}); // TODO: Remove URL hacks when the mobile clients eventually support v2 widgets const parsedUrl = new URL(widgetUrl); parsedUrl.search = ''; // set to empty string to make the URL class use searchParams instead parsedUrl.searchParams.set('confId', confId); - parsedUrl.searchParams.set('auth', jitsiAuth); widgetUrl = parsedUrl.toString(); const widgetData = { @@ -419,6 +418,7 @@ async function _startCallApp(roomId, type) { isAudioOnly: type === 'voice', domain: jitsiDomain, auth: jitsiAuth, + roomId: roomId, }; const widgetId = ( diff --git a/src/components/views/elements/AppTile.js b/src/components/views/elements/AppTile.js index 299025f949..9e0dd3c6c2 100644 --- a/src/components/views/elements/AppTile.js +++ b/src/components/views/elements/AppTile.js @@ -603,6 +603,7 @@ export default class AppTile extends React.Component { // TODO: Namespace themes through some standard 'theme': SettingsStore.getValue("theme"), }); + console.log("DEBUG TEMPLATEDURL APPTILE", vars); if (vars.conferenceId === undefined) { // we'll need to parse the conference ID out of the URL for v1 Jitsi widgets @@ -626,7 +627,10 @@ export default class AppTile extends React.Component { if (WidgetType.JITSI.matches(this.props.app.type)) { console.log("Replacing Jitsi widget URL with local wrapper"); - url = WidgetUtils.getLocalJitsiWrapperUrl({forLocalRender: true}); + url = WidgetUtils.getLocalJitsiWrapperUrl({ + forLocalRender: true, + auth: this.props.app.data ? this.props.app.data.auth : null, + }); url = this._addWurlParams(url); } else { url = this._getSafeUrl(this.state.widgetUrl); @@ -637,7 +641,10 @@ export default class AppTile extends React.Component { _getPopoutUrl() { if (WidgetType.JITSI.matches(this.props.app.type)) { return this._templatedUrl( - WidgetUtils.getLocalJitsiWrapperUrl({forLocalRender: false}), + WidgetUtils.getLocalJitsiWrapperUrl({ + forLocalRender: false, + auth: this.props.app.data ? this.props.app.data.auth : null, + }), this.props.app.type, ); } else { diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 645953210d..c9666d90d5 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -448,16 +448,21 @@ export default class WidgetUtils { return encodeURIComponent(`${widgetLocation}::${widgetUrl}`); } - static getLocalJitsiWrapperUrl(opts: {forLocalRender?: boolean}={}) { + static getLocalJitsiWrapperUrl(opts: {forLocalRender?: boolean, auth?: string}={}) { // NB. we can't just encodeURIComponent all of these because the $ signs need to be there - const queryString = [ + const queryParts = [ 'conferenceDomain=$domain', 'conferenceId=$conferenceId', 'isAudioOnly=$isAudioOnly', 'displayName=$matrix_display_name', 'avatarUrl=$matrix_avatar_url', 'userId=$matrix_user_id', - ].join('&'); + 'roomId=$matrix_room_id', + ]; + if (opts.auth) { + queryParts.push(`auth=${opts.auth}`); + } + const queryString = queryParts.join('&'); let baseUrl = window.location; if (window.location.protocol !== "https:" && !opts.forLocalRender) {