Unverified Commit aaca4ad2 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by GitHub
Browse files

[NEW] Jitsi JWT added to URL (#1746)

parent 270ec794
......@@ -35,6 +35,9 @@ export default {
Jitsi_Domain: {
type: 'valueAsString'
},
Jitsi_Enabled_TokenAuth: {
type: 'valueAsBoolean'
},
Jitsi_URL_Room_Prefix: {
type: 'valueAsString'
},
......
......@@ -17,10 +17,25 @@ const jitsiBaseUrl = ({
return `${ urlProtocol }${ urlDomain }${ prefix }${ uniqueIdentifier }`;
};
function callJitsi(rid, onlyAudio = false) {
async function callJitsi(rid, onlyAudio = false) {
let accessToken;
let queryString = '';
const { settings } = reduxStore.getState();
const { Jitsi_Enabled_TokenAuth } = settings;
Navigation.navigate('JitsiMeetView', { url: `${ jitsiBaseUrl(settings) }${ rid }`, onlyAudio, rid });
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;
......@@ -2,14 +2,27 @@ import React from 'react';
import PropTypes from 'prop-types';
import JitsiMeet, { JitsiMeetView as RNJitsiMeetView } from 'react-native-jitsi-meet';
import BackgroundTimer from 'react-native-background-timer';
import { connect } from 'react-redux';
import RocketChat from '../lib/rocketchat';
import { getUserSelector } from '../selectors/login';
import sharedStyles from './Styles';
const formatUrl = (url, baseUrl, uriSize, avatarAuthURLFragment) => (
`${ baseUrl }/avatar/${ url }?format=png&width=${ uriSize }&height=${ uriSize }${ avatarAuthURLFragment }`
);
class JitsiMeetView extends React.Component {
static propTypes = {
navigation: PropTypes.object
navigation: PropTypes.object,
baseUrl: PropTypes.string,
user: PropTypes.shape({
id: PropTypes.string,
username: PropTypes.string,
name: PropTypes.string,
token: PropTypes.string
})
}
constructor(props) {
......@@ -21,14 +34,25 @@ class JitsiMeetView extends React.Component {
}
componentDidMount() {
const { navigation } = this.props;
const { navigation, user, baseUrl } = this.props;
const {
name: displayName, id: userId, token, username
} = user;
const avatarAuthURLFragment = `&rc_token=${ token }&rc_uid=${ userId }`;
const avatar = formatUrl(username, baseUrl, 100, avatarAuthURLFragment);
setTimeout(() => {
const userInfo = {
displayName,
avatar
};
const url = navigation.getParam('url');
const onlyAudio = navigation.getParam('onlyAudio', false);
if (onlyAudio) {
JitsiMeet.audioCall(url);
JitsiMeet.audioCall(url, userInfo);
} else {
JitsiMeet.call(url);
JitsiMeet.call(url, userInfo);
}
}, 1000);
}
......@@ -71,4 +95,9 @@ class JitsiMeetView extends React.Component {
}
}
export default JitsiMeetView;
const mapStateToProps = state => ({
user: getUserSelector(state),
baseUrl: state.server.server
});
export default connect(mapStateToProps)(JitsiMeetView);
......@@ -296,7 +296,7 @@ PODS:
- React
- react-native-document-picker (3.2.4):
- React
- react-native-jitsi-meet (2.0.4):
- react-native-jitsi-meet (2.1.0):
- JitsiMeetSDK
- React
- react-native-keyboard-input (5.3.1):
......@@ -753,7 +753,7 @@ SPEC CHECKSUMS:
react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b
react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320
react-native-document-picker: c36bf5f067a581657ecaf7124dcd921a8be19061
react-native-jitsi-meet: 5bc06e8b65a7d04fd3705d5720f3b2ec66e49a29
react-native-jitsi-meet: 04ccc47303c62ba2b7e7407a113f5f46241ebd75
react-native-keyboard-input: 2a01e0aceac330592bbe9b3101761bb9d8e6d1fb
react-native-keyboard-tracking-view: 4bb67b89ccd327c7d9eab87f722880d2103a25a8
react-native-notifications: 163ddedac6fcc8d850ea15b06abdadcacdff00f1
......
{
"name": "react-native-jitsi-meet",
"version": "2.0.4",
"version": "2.1.0",
"summary": "Jitsi Meet SDK wrapper for React Native.",
"license": "Apache-2.0",
"authors": {
......@@ -13,7 +13,7 @@
},
"source": {
"git": "https://github.com/skrafft/react-native-jitsi-meet.git",
"tag": "v2.0.4"
"tag": "v2.1.0"
},
"source_files": "ios/**/*.{h,m}",
"dependencies": {
......
......@@ -296,7 +296,7 @@ PODS:
- React
- react-native-document-picker (3.2.4):
- React
- react-native-jitsi-meet (2.0.4):
- react-native-jitsi-meet (2.1.0):
- JitsiMeetSDK
- React
- react-native-keyboard-input (5.3.1):
......@@ -753,7 +753,7 @@ SPEC CHECKSUMS:
react-native-background-timer: 1b6e6b4e10f1b74c367a1fdc3c72b67c619b222b
react-native-cameraroll: 463aff54e37cff27ea76eb792e6f1fa43b876320
react-native-document-picker: c36bf5f067a581657ecaf7124dcd921a8be19061
react-native-jitsi-meet: 5bc06e8b65a7d04fd3705d5720f3b2ec66e49a29
react-native-jitsi-meet: 04ccc47303c62ba2b7e7407a113f5f46241ebd75
react-native-keyboard-input: 2a01e0aceac330592bbe9b3101761bb9d8e6d1fb
react-native-keyboard-tracking-view: 4bb67b89ccd327c7d9eab87f722880d2103a25a8
react-native-notifications: 163ddedac6fcc8d850ea15b06abdadcacdff00f1
......
......@@ -9493,8 +9493,8 @@ react-native-iphone-x-helper@^1.0.3:
integrity sha512-xIeTo4s77wwKgBZLVRIZC9tM9/PkXS46Ul76NXmvmixEb3ZwqGdQesR3zRiLMOoIdfOURB6N9bba9po7+x9Bag==
 
react-native-jitsi-meet@RocketChat/react-native-jitsi-meet:
version "2.0.4"
resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/5f535b301d18a26860e2e04ca5b164a564184b48"
version "2.1.0"
resolved "https://codeload.github.com/RocketChat/react-native-jitsi-meet/tar.gz/351789a80ba5c05f27b702e69d3354f0e3651a49"
 
react-native-keyboard-aware-scroll-view@0.9.1:
version "0.9.1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment