[FIX] Support Jitsi_URL_Room_Hash (#2905)

This commit is contained in:
Diego Mello 2021-02-22 18:37:13 -03:00 committed by GitHub
parent 3532cb349c
commit f579641660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 14 deletions

View File

@ -101,6 +101,9 @@ export default {
Jitsi_Enabled_TokenAuth: { Jitsi_Enabled_TokenAuth: {
type: 'valueAsBoolean' type: 'valueAsBoolean'
}, },
Jitsi_URL_Room_Hash: {
type: 'valueAsBoolean'
},
Jitsi_URL_Room_Prefix: { Jitsi_URL_Room_Prefix: {
type: 'valueAsString' type: 'valueAsString'
}, },

View File

@ -2,7 +2,7 @@ import reduxStore from '../createStore';
import Navigation from '../Navigation'; import Navigation from '../Navigation';
import { logEvent, events } from '../../utils/log'; import { logEvent, events } from '../../utils/log';
async function jitsiURL({ rid }) { async function jitsiURL({ room }) {
const { settings } = reduxStore.getState(); const { settings } = reduxStore.getState();
const { Jitsi_Enabled } = settings; const { Jitsi_Enabled } = settings;
@ -11,31 +11,37 @@ async function jitsiURL({ rid }) {
} }
const { const {
Jitsi_Domain, Jitsi_URL_Room_Prefix, Jitsi_SSL, Jitsi_Enabled_TokenAuth, uniqueID Jitsi_Domain, Jitsi_URL_Room_Prefix, Jitsi_SSL, Jitsi_Enabled_TokenAuth, uniqueID, Jitsi_URL_Room_Hash
} = settings; } = settings;
const domain = `${ Jitsi_Domain }/`; const domain = `${ Jitsi_Domain }/`;
const prefix = Jitsi_URL_Room_Prefix; const prefix = Jitsi_URL_Room_Prefix;
const uniqueIdentifier = uniqueID || 'undefined';
const protocol = Jitsi_SSL ? 'https://' : 'http://'; const protocol = Jitsi_SSL ? 'https://' : 'http://';
let queryString = ''; let queryString = '';
if (Jitsi_Enabled_TokenAuth) { if (Jitsi_Enabled_TokenAuth) {
try { try {
const accessToken = await this.methodCallWrapper('jitsi:generateAccessToken', rid); const accessToken = await this.methodCallWrapper('jitsi:generateAccessToken', room?.rid);
queryString = `?jwt=${ accessToken }`; queryString = `?jwt=${ accessToken }`;
} catch { } catch {
logEvent(events.RA_JITSI_F); logEvent(events.RA_JITSI_F);
} }
} }
return `${ protocol }${ domain }${ prefix }${ uniqueIdentifier }${ rid }${ queryString }`; let rname;
if (Jitsi_URL_Room_Hash) {
rname = uniqueID + room?.rid;
} else {
rname = encodeURIComponent(room.t === 'd' ? room?.usernames?.join?.(' x ') : room?.name);
} }
async function callJitsi(rid, onlyAudio = false) { return `${ protocol }${ domain }${ prefix }${ rname }${ queryString }`;
}
async function callJitsi(room, onlyAudio = false) {
logEvent(onlyAudio ? events.RA_JITSI_AUDIO : events.RA_JITSI_VIDEO); logEvent(onlyAudio ? events.RA_JITSI_AUDIO : events.RA_JITSI_VIDEO);
const url = await jitsiURL.call(this, { rid }); const url = await jitsiURL.call(this, { room });
Navigation.navigate('JitsiMeetView', { url, onlyAudio, rid }); Navigation.navigate('JitsiMeetView', { url, onlyAudio, rid: room?.rid });
} }
export default callJitsi; export default callJitsi;

View File

@ -75,7 +75,8 @@ export default async function canOpenRoom({ rid, path, isCall }) {
name: room.name, name: room.name,
fname: room.fname, fname: room.fname,
prid: room.prid, prid: room.prid,
uids: room.uids uids: room.uids,
usernames: room.usernames
}; };
} catch (e) { } catch (e) {
// Do nothing // Do nothing

View File

@ -53,7 +53,7 @@ const navigate = function* navigate({ params }) {
yield goRoom({ item, isMasterDetail }); yield goRoom({ item, isMasterDetail });
if (params.isCall) { if (params.isCall) {
RocketChat.callJitsi(item.rid); RocketChat.callJitsi(item);
} }
} }
} else { } else {

View File

@ -482,7 +482,7 @@ class RoomActionsView extends React.Component {
<List.Separator /> <List.Separator />
<List.Item <List.Item
title='Voice_call' title='Voice_call'
onPress={() => RocketChat.callJitsi(room?.rid, true)} onPress={() => RocketChat.callJitsi(room, true)}
testID='room-actions-voice' testID='room-actions-voice'
left={() => <List.Icon name='phone' />} left={() => <List.Icon name='phone' />}
showActionIndicator showActionIndicator
@ -490,7 +490,7 @@ class RoomActionsView extends React.Component {
<List.Separator /> <List.Separator />
<List.Item <List.Item
title='Video_call' title='Video_call'
onPress={() => RocketChat.callJitsi(room?.rid)} onPress={() => RocketChat.callJitsi(room)}
testID='room-actions-video' testID='room-actions-video'
left={() => <List.Icon name='camera' />} left={() => <List.Icon name='camera' />}
showActionIndicator showActionIndicator

View File

@ -276,7 +276,7 @@ class RoomInfoView extends React.Component {
videoCall = () => { videoCall = () => {
const { room } = this.state; const { room } = this.state;
RocketChat.callJitsi(room.rid); RocketChat.callJitsi(room);
} }
renderAvatar = (room, roomUser) => { renderAvatar = (room, roomUser) => {

View File

@ -817,7 +817,7 @@ class RoomView extends React.Component {
if (jitsiTimeout < Date.now()) { if (jitsiTimeout < Date.now()) {
showErrorAlert(I18n.t('Call_already_ended')); showErrorAlert(I18n.t('Call_already_ended'));
} else { } else {
RocketChat.callJitsi(this.rid); RocketChat.callJitsi(room);
} }
}; };