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.
pull/21833/head
Jason Robinson 2020-09-04 12:42:46 +03:00
parent a511ad6633
commit baa6d8a294
3 changed files with 19 additions and 7 deletions

View File

@ -405,13 +405,12 @@ async function _startCallApp(roomId, type) {
confId = `JitsiConference${generateHumanReadableId()}`; 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 // TODO: Remove URL hacks when the mobile clients eventually support v2 widgets
const parsedUrl = new URL(widgetUrl); const parsedUrl = new URL(widgetUrl);
parsedUrl.search = ''; // set to empty string to make the URL class use searchParams instead parsedUrl.search = ''; // set to empty string to make the URL class use searchParams instead
parsedUrl.searchParams.set('confId', confId); parsedUrl.searchParams.set('confId', confId);
parsedUrl.searchParams.set('auth', jitsiAuth);
widgetUrl = parsedUrl.toString(); widgetUrl = parsedUrl.toString();
const widgetData = { const widgetData = {
@ -419,6 +418,7 @@ async function _startCallApp(roomId, type) {
isAudioOnly: type === 'voice', isAudioOnly: type === 'voice',
domain: jitsiDomain, domain: jitsiDomain,
auth: jitsiAuth, auth: jitsiAuth,
roomId: roomId,
}; };
const widgetId = ( const widgetId = (

View File

@ -603,6 +603,7 @@ export default class AppTile extends React.Component {
// TODO: Namespace themes through some standard // TODO: Namespace themes through some standard
'theme': SettingsStore.getValue("theme"), 'theme': SettingsStore.getValue("theme"),
}); });
console.log("DEBUG TEMPLATEDURL APPTILE", vars);
if (vars.conferenceId === undefined) { if (vars.conferenceId === undefined) {
// we'll need to parse the conference ID out of the URL for v1 Jitsi widgets // 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)) { if (WidgetType.JITSI.matches(this.props.app.type)) {
console.log("Replacing Jitsi widget URL with local wrapper"); 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); url = this._addWurlParams(url);
} else { } else {
url = this._getSafeUrl(this.state.widgetUrl); url = this._getSafeUrl(this.state.widgetUrl);
@ -637,7 +641,10 @@ export default class AppTile extends React.Component {
_getPopoutUrl() { _getPopoutUrl() {
if (WidgetType.JITSI.matches(this.props.app.type)) { if (WidgetType.JITSI.matches(this.props.app.type)) {
return this._templatedUrl( 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, this.props.app.type,
); );
} else { } else {

View File

@ -448,16 +448,21 @@ export default class WidgetUtils {
return encodeURIComponent(`${widgetLocation}::${widgetUrl}`); 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 // NB. we can't just encodeURIComponent all of these because the $ signs need to be there
const queryString = [ const queryParts = [
'conferenceDomain=$domain', 'conferenceDomain=$domain',
'conferenceId=$conferenceId', 'conferenceId=$conferenceId',
'isAudioOnly=$isAudioOnly', 'isAudioOnly=$isAudioOnly',
'displayName=$matrix_display_name', 'displayName=$matrix_display_name',
'avatarUrl=$matrix_avatar_url', 'avatarUrl=$matrix_avatar_url',
'userId=$matrix_user_id', '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; let baseUrl = window.location;
if (window.location.protocol !== "https:" && !opts.forLocalRender) { if (window.location.protocol !== "https:" && !opts.forLocalRender) {