Pārlūkot izejas kodu

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
j8
Paweł Domas 8 gadus atpakaļ
vecāks
revīzija
e553e61f04

+ 16
- 2
react/features/invite/components/AddPeopleDialog.web.js Parādīt failu

@@ -10,7 +10,7 @@ import { translate } from '../../base/i18n';
10 10
 import MultiSelectAutocomplete
11 11
     from '../../base/react/components/web/MultiSelectAutocomplete';
12 12
 
13
-import { invitePeople, searchPeople } from '../functions';
13
+import { invitePeople, inviteRooms, searchPeople } from '../functions';
14 14
 
15 15
 declare var interfaceConfig: Object;
16 16
 
@@ -26,6 +26,12 @@ class AddPeopleDialog extends Component {
26 26
      * @static
27 27
      */
28 28
     static propTypes = {
29
+        /**
30
+         * The {@link JitsiMeetConference} which will be used to invite "room"
31
+         * participants through the SIP Jibri (Video SIP gateway).
32
+         */
33
+        _conference: PropTypes.object,
34
+
29 35
         /**
30 36
          * The URL pointing to the service allowing for people invite.
31 37
          */
@@ -229,11 +235,17 @@ class AddPeopleDialog extends Component {
229 235
                 addToCallInProgress: true
230 236
             });
231 237
 
238
+            this.props._conference
239
+                && inviteRooms(
240
+                    this.props._conference,
241
+                    this.state.inviteItems.filter(
242
+                        i => i.type === 'videosipgw'));
243
+
232 244
             invitePeople(
233 245
                 this.props._inviteServiceUrl,
234 246
                 this.props._inviteUrl,
235 247
                 this.props._jwt,
236
-                this.state.inviteItems)
248
+                this.state.inviteItems.filter(i => i.type === 'user'))
237 249
             .then(() => {
238 250
                 this.setState({
239 251
                     addToCallInProgress: false
@@ -318,6 +330,7 @@ class AddPeopleDialog extends Component {
318 330
  * }}
319 331
  */
320 332
 function _mapStateToProps(state) {
333
+    const { conference } = state['features/base/conference'];
321 334
     const {
322 335
         inviteServiceUrl,
323 336
         peopleSearchQueryTypes,
@@ -325,6 +338,7 @@ function _mapStateToProps(state) {
325 338
      } = state['features/base/config'];
326 339
 
327 340
     return {
341
+        _conference: conference,
328 342
         _jwt: state['features/jwt'].jwt,
329 343
         _inviteUrl: getInviteURL(state),
330 344
         _inviteServiceUrl: inviteServiceUrl,

+ 29
- 3
react/features/invite/functions.js Parādīt failu

@@ -35,14 +35,14 @@ export function searchPeople(// eslint-disable-line max-params
35 35
  * invitation.
36 36
  * @param {string} inviteUrl - The url to the conference.
37 37
  * @param {string} jwt - The jwt token to pass to the search service.
38
- * @param {Immutable.List} inviteItems - The list of items to invite.
38
+ * @param {Immutable.List} people - The list of the "user" type items to invite.
39 39
  * @returns {Promise} - The promise created by the request.
40 40
  */
41
-export function invitePeople(inviteServiceUrl, inviteUrl, jwt, inviteItems) { // eslint-disable-line max-params, max-len
41
+export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // eslint-disable-line max-params, max-len
42 42
     return new Promise((resolve, reject) => {
43 43
         $.post(`${inviteServiceUrl}?token=${jwt}`,
44 44
             JSON.stringify({
45
-                'invited': inviteItems,
45
+                'invited': people,
46 46
                 'url': inviteUrl }),
47 47
             response => resolve(response),
48 48
             'json')
@@ -51,3 +51,29 @@ export function invitePeople(inviteServiceUrl, inviteUrl, jwt, inviteItems) { //
51 51
             );
52 52
     });
53 53
 }
54
+
55
+/**
56
+ * Invites room participants to the conference through the SIP Jibri service.
57
+ *
58
+ * @param {JitsiMeetConference} conference - The conference to which the rooms
59
+ * will be invited to.
60
+ * @param {Immutable.List} rooms - The list of the "videosipgw" type items to
61
+ * invite.
62
+ * @returns {void}
63
+ */
64
+export function inviteRooms(conference, rooms) {
65
+    for (const room of rooms) {
66
+        const sipAddress = room.id;
67
+        const displayName = room.name;
68
+
69
+        if (sipAddress && displayName) {
70
+            const newSession
71
+                = conference.createVideoSIPGWSession(sipAddress, displayName);
72
+
73
+            newSession.start();
74
+        } else {
75
+            console.error(
76
+                `No display name or sip number for ${JSON.stringify(room)}`);
77
+        }
78
+    }
79
+}

Notiek ielāde…
Atcelt
Saglabāt