diff --git a/app/constants/settings.js b/app/constants/settings.js index 359dff092..9f0df8865 100644 --- a/app/constants/settings.js +++ b/app/constants/settings.js @@ -101,6 +101,9 @@ export default { Jitsi_Enabled_TokenAuth: { type: 'valueAsBoolean' }, + Jitsi_URL_Room_Hash: { + type: 'valueAsBoolean' + }, Jitsi_URL_Room_Prefix: { type: 'valueAsString' }, diff --git a/app/lib/methods/callJitsi.js b/app/lib/methods/callJitsi.js index 7410ed8bd..7275ef812 100644 --- a/app/lib/methods/callJitsi.js +++ b/app/lib/methods/callJitsi.js @@ -2,7 +2,7 @@ import reduxStore from '../createStore'; import Navigation from '../Navigation'; import { logEvent, events } from '../../utils/log'; -async function jitsiURL({ rid }) { +async function jitsiURL({ room }) { const { settings } = reduxStore.getState(); const { Jitsi_Enabled } = settings; @@ -11,31 +11,37 @@ async function jitsiURL({ rid }) { } 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; const domain = `${ Jitsi_Domain }/`; const prefix = Jitsi_URL_Room_Prefix; - const uniqueIdentifier = uniqueID || 'undefined'; const protocol = Jitsi_SSL ? 'https://' : 'http://'; let queryString = ''; if (Jitsi_Enabled_TokenAuth) { try { - const accessToken = await this.methodCallWrapper('jitsi:generateAccessToken', rid); + const accessToken = await this.methodCallWrapper('jitsi:generateAccessToken', room?.rid); queryString = `?jwt=${ accessToken }`; } catch { 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); + } + + return `${ protocol }${ domain }${ prefix }${ rname }${ queryString }`; } -async function callJitsi(rid, onlyAudio = false) { +async function callJitsi(room, onlyAudio = false) { logEvent(onlyAudio ? events.RA_JITSI_AUDIO : events.RA_JITSI_VIDEO); - const url = await jitsiURL.call(this, { rid }); - Navigation.navigate('JitsiMeetView', { url, onlyAudio, rid }); + const url = await jitsiURL.call(this, { room }); + Navigation.navigate('JitsiMeetView', { url, onlyAudio, rid: room?.rid }); } export default callJitsi; diff --git a/app/lib/methods/canOpenRoom.js b/app/lib/methods/canOpenRoom.js index b85728727..343d49445 100644 --- a/app/lib/methods/canOpenRoom.js +++ b/app/lib/methods/canOpenRoom.js @@ -75,7 +75,8 @@ export default async function canOpenRoom({ rid, path, isCall }) { name: room.name, fname: room.fname, prid: room.prid, - uids: room.uids + uids: room.uids, + usernames: room.usernames }; } catch (e) { // Do nothing diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js index caf2a46f9..e0961c7cf 100644 --- a/app/sagas/deepLinking.js +++ b/app/sagas/deepLinking.js @@ -53,7 +53,7 @@ const navigate = function* navigate({ params }) { yield goRoom({ item, isMasterDetail }); if (params.isCall) { - RocketChat.callJitsi(item.rid); + RocketChat.callJitsi(item); } } } else { diff --git a/app/views/RoomActionsView/index.js b/app/views/RoomActionsView/index.js index 43e58a901..96319edba 100644 --- a/app/views/RoomActionsView/index.js +++ b/app/views/RoomActionsView/index.js @@ -482,7 +482,7 @@ class RoomActionsView extends React.Component { RocketChat.callJitsi(room?.rid, true)} + onPress={() => RocketChat.callJitsi(room, true)} testID='room-actions-voice' left={() => } showActionIndicator @@ -490,7 +490,7 @@ class RoomActionsView extends React.Component { RocketChat.callJitsi(room?.rid)} + onPress={() => RocketChat.callJitsi(room)} testID='room-actions-video' left={() => } showActionIndicator diff --git a/app/views/RoomInfoView/index.js b/app/views/RoomInfoView/index.js index fd61e0eae..f34fab6f3 100644 --- a/app/views/RoomInfoView/index.js +++ b/app/views/RoomInfoView/index.js @@ -276,7 +276,7 @@ class RoomInfoView extends React.Component { videoCall = () => { const { room } = this.state; - RocketChat.callJitsi(room.rid); + RocketChat.callJitsi(room); } renderAvatar = (room, roomUser) => { diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index e85784958..e17ff1cd1 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -817,7 +817,7 @@ class RoomView extends React.Component { if (jitsiTimeout < Date.now()) { showErrorAlert(I18n.t('Call_already_ended')); } else { - RocketChat.callJitsi(this.rid); + RocketChat.callJitsi(room); } };