2019-10-07 20:56:30 +00:00
|
|
|
import reduxStore from '../createStore';
|
|
|
|
import Navigation from '../Navigation';
|
|
|
|
|
|
|
|
const jitsiBaseUrl = ({
|
|
|
|
Jitsi_Enabled, Jitsi_SSL, Jitsi_Domain, Jitsi_URL_Room_Prefix, uniqueID
|
|
|
|
}) => {
|
|
|
|
if (!Jitsi_Enabled) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
const uniqueIdentifier = uniqueID || 'undefined';
|
|
|
|
const domain = Jitsi_Domain;
|
|
|
|
const prefix = Jitsi_URL_Room_Prefix;
|
|
|
|
|
|
|
|
const urlProtocol = Jitsi_SSL ? 'https://' : 'http://';
|
|
|
|
const urlDomain = `${ domain }/`;
|
|
|
|
|
|
|
|
return `${ urlProtocol }${ urlDomain }${ prefix }${ uniqueIdentifier }`;
|
|
|
|
};
|
|
|
|
|
2020-02-19 19:43:47 +00:00
|
|
|
async function callJitsi(rid, onlyAudio = false) {
|
|
|
|
let accessToken;
|
|
|
|
let queryString = '';
|
2019-10-07 20:56:30 +00:00
|
|
|
const { settings } = reduxStore.getState();
|
2020-02-19 19:43:47 +00:00
|
|
|
const { Jitsi_Enabled_TokenAuth } = settings;
|
2019-10-07 20:56:30 +00:00
|
|
|
|
2020-02-19 19:43:47 +00:00
|
|
|
if (Jitsi_Enabled_TokenAuth) {
|
|
|
|
try {
|
|
|
|
accessToken = await this.sdk.methodCall('jitsi:generateAccessToken', rid);
|
|
|
|
} catch (e) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (accessToken) {
|
|
|
|
queryString = `?jwt=${ accessToken }`;
|
|
|
|
}
|
|
|
|
|
|
|
|
Navigation.navigate('JitsiMeetView', { url: `${ jitsiBaseUrl(settings) }${ rid }${ queryString }`, onlyAudio, rid });
|
2019-10-07 20:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default callJitsi;
|