feat(AddPeopleDialog): invite rooms (#2001)

* feat(AddPeopleDialog): invite rooms

Distinguish between 'user' and 'videosipgw' search result items and
invite them with using different method.

* squash: fix typo in AddPeopleDialog.web.js
This commit is contained in:
Paweł Domas 2017-09-21 15:24:56 -05:00 committed by virtuacoplenny
parent a0a4fbf566
commit e553e61f04
2 changed files with 45 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import { translate } from '../../base/i18n';
import MultiSelectAutocomplete
from '../../base/react/components/web/MultiSelectAutocomplete';
import { invitePeople, searchPeople } from '../functions';
import { invitePeople, inviteRooms, searchPeople } from '../functions';
declare var interfaceConfig: Object;
@ -26,6 +26,12 @@ class AddPeopleDialog extends Component {
* @static
*/
static propTypes = {
/**
* The {@link JitsiMeetConference} which will be used to invite "room"
* participants through the SIP Jibri (Video SIP gateway).
*/
_conference: PropTypes.object,
/**
* The URL pointing to the service allowing for people invite.
*/
@ -229,11 +235,17 @@ class AddPeopleDialog extends Component {
addToCallInProgress: true
});
this.props._conference
&& inviteRooms(
this.props._conference,
this.state.inviteItems.filter(
i => i.type === 'videosipgw'));
invitePeople(
this.props._inviteServiceUrl,
this.props._inviteUrl,
this.props._jwt,
this.state.inviteItems)
this.state.inviteItems.filter(i => i.type === 'user'))
.then(() => {
this.setState({
addToCallInProgress: false
@ -318,6 +330,7 @@ class AddPeopleDialog extends Component {
* }}
*/
function _mapStateToProps(state) {
const { conference } = state['features/base/conference'];
const {
inviteServiceUrl,
peopleSearchQueryTypes,
@ -325,6 +338,7 @@ function _mapStateToProps(state) {
} = state['features/base/config'];
return {
_conference: conference,
_jwt: state['features/jwt'].jwt,
_inviteUrl: getInviteURL(state),
_inviteServiceUrl: inviteServiceUrl,

View File

@ -35,14 +35,14 @@ export function searchPeople(// eslint-disable-line max-params
* invitation.
* @param {string} inviteUrl - The url to the conference.
* @param {string} jwt - The jwt token to pass to the search service.
* @param {Immutable.List} inviteItems - The list of items to invite.
* @param {Immutable.List} people - The list of the "user" type items to invite.
* @returns {Promise} - The promise created by the request.
*/
export function invitePeople(inviteServiceUrl, inviteUrl, jwt, inviteItems) { // eslint-disable-line max-params, max-len
export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // eslint-disable-line max-params, max-len
return new Promise((resolve, reject) => {
$.post(`${inviteServiceUrl}?token=${jwt}`,
JSON.stringify({
'invited': inviteItems,
'invited': people,
'url': inviteUrl }),
response => resolve(response),
'json')
@ -51,3 +51,29 @@ export function invitePeople(inviteServiceUrl, inviteUrl, jwt, inviteItems) { //
);
});
}
/**
* Invites room participants to the conference through the SIP Jibri service.
*
* @param {JitsiMeetConference} conference - The conference to which the rooms
* will be invited to.
* @param {Immutable.List} rooms - The list of the "videosipgw" type items to
* invite.
* @returns {void}
*/
export function inviteRooms(conference, rooms) {
for (const room of rooms) {
const sipAddress = room.id;
const displayName = room.name;
if (sipAddress && displayName) {
const newSession
= conference.createVideoSIPGWSession(sipAddress, displayName);
newSession.start();
} else {
console.error(
`No display name or sip number for ${JSON.stringify(room)}`);
}
}
}