verdnatura-chat/app/lib/methods/callJitsi.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

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 = '';
const { settings } = reduxStore.getState();
2020-02-19 19:43:47 +00:00
const { Jitsi_Enabled_TokenAuth } = settings;
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 });
}
export default callJitsi;