浏览代码

Merge pull request #9184 from jitsi/tavram/invite-types

fix(invite) fix notifications for phone invites
j8
Avram Tudor 4 年前
父节点
当前提交
6e91665987
没有帐户链接到提交者的电子邮件

+ 9
- 8
react/features/invite/actions.any.js 查看文件

15
     UPDATE_DIAL_IN_NUMBERS_FAILED,
15
     UPDATE_DIAL_IN_NUMBERS_FAILED,
16
     UPDATE_DIAL_IN_NUMBERS_SUCCESS
16
     UPDATE_DIAL_IN_NUMBERS_SUCCESS
17
 } from './actionTypes';
17
 } from './actionTypes';
18
+import { INVITE_TYPES } from './constants';
18
 import {
19
 import {
19
     getDialInConferenceID,
20
     getDialInConferenceID,
20
     getDialInNumbers,
21
     getDialInNumbers,
76
         if (showCalleeInfo
77
         if (showCalleeInfo
77
                 && !calleeInfoVisible
78
                 && !calleeInfoVisible
78
                 && invitees.length === 1
79
                 && invitees.length === 1
79
-                && invitees[0].type === 'user'
80
+                && invitees[0].type === INVITE_TYPES.USER
80
                 && participants.length === 1) {
81
                 && participants.length === 1) {
81
             dispatch(setCalleeInfoVisible(true, invitees[0]));
82
             dispatch(setCalleeInfoVisible(true, invitees[0]));
82
         }
83
         }
110
 
111
 
111
         // First create all promises for dialing out.
112
         // First create all promises for dialing out.
112
         const phoneNumbers
113
         const phoneNumbers
113
-            = invitesLeftToSend.filter(({ type }) => type === 'phone');
114
+            = invitesLeftToSend.filter(({ type }) => type === INVITE_TYPES.PHONE);
114
 
115
 
115
         // For each number, dial out. On success, remove the number from
116
         // For each number, dial out. On success, remove the number from
116
         // {@link invitesLeftToSend}.
117
         // {@link invitesLeftToSend}.
131
 
132
 
132
         const usersAndRooms
133
         const usersAndRooms
133
             = invitesLeftToSend.filter(
134
             = invitesLeftToSend.filter(
134
-                ({ type }) => type === 'user' || type === 'room');
135
+                ({ type }) => [ INVITE_TYPES.USER, INVITE_TYPES.ROOM ].includes(type));
135
 
136
 
136
         if (usersAndRooms.length) {
137
         if (usersAndRooms.length) {
137
             // Send a request to invite all the rooms and users. On success,
138
             // Send a request to invite all the rooms and users. On success,
146
                 .then(() => {
147
                 .then(() => {
147
                     invitesLeftToSend
148
                     invitesLeftToSend
148
                         = invitesLeftToSend.filter(
149
                         = invitesLeftToSend.filter(
149
-                            ({ type }) => type !== 'user' && type !== 'room');
150
+                            ({ type }) => ![ INVITE_TYPES.USER, INVITE_TYPES.ROOM ].includes(type));
150
                 })
151
                 })
151
                 .catch(error => {
152
                 .catch(error => {
152
                     dispatch(setCalleeInfoVisible(false));
153
                     dispatch(setCalleeInfoVisible(false));
159
         // Sipgw calls are fire and forget. Invite them to the conference, then
160
         // Sipgw calls are fire and forget. Invite them to the conference, then
160
         // immediately remove them from invitesLeftToSend.
161
         // immediately remove them from invitesLeftToSend.
161
         const vrooms
162
         const vrooms
162
-            = invitesLeftToSend.filter(({ type }) => type === 'videosipgw');
163
+            = invitesLeftToSend.filter(({ type }) => type === INVITE_TYPES.VIDEO_ROOM);
163
 
164
 
164
         conference
165
         conference
165
             && vrooms.length > 0
166
             && vrooms.length > 0
166
             && dispatch(inviteVideoRooms(conference, vrooms));
167
             && dispatch(inviteVideoRooms(conference, vrooms));
167
 
168
 
168
         invitesLeftToSend
169
         invitesLeftToSend
169
-            = invitesLeftToSend.filter(({ type }) => type !== 'videosipgw');
170
+            = invitesLeftToSend.filter(({ type }) => type !== INVITE_TYPES.VIDEO_ROOM);
170
 
171
 
171
         const sipEndpoints
172
         const sipEndpoints
172
-            = invitesLeftToSend.filter(({ type }) => type === 'sip');
173
+            = invitesLeftToSend.filter(({ type }) => type === INVITE_TYPES.SIP);
173
 
174
 
174
         conference && inviteSipEndpoints(
175
         conference && inviteSipEndpoints(
175
             sipEndpoints,
176
             sipEndpoints,
182
         );
183
         );
183
 
184
 
184
         invitesLeftToSend
185
         invitesLeftToSend
185
-            = invitesLeftToSend.filter(({ type }) => type !== 'sip');
186
+            = invitesLeftToSend.filter(({ type }) => type !== INVITE_TYPES.SIP);
186
 
187
 
187
         return (
188
         return (
188
             Promise.all(allInvitePromises)
189
             Promise.all(allInvitePromises)

+ 23
- 4
react/features/invite/components/add-people-dialog/AbstractAddPeopleDialog.js 查看文件

8
     showNotification
8
     showNotification
9
 } from '../../../notifications';
9
 } from '../../../notifications';
10
 import { invite } from '../../actions';
10
 import { invite } from '../../actions';
11
+import { INVITE_TYPES } from '../../constants';
11
 import {
12
 import {
12
     getInviteResultsForQuery,
13
     getInviteResultsForQuery,
13
     getInviteTypeCounts,
14
     getInviteTypeCounts,
100
         this._query = this._query.bind(this);
101
         this._query = this._query.bind(this);
101
     }
102
     }
102
 
103
 
104
+    /**
105
+     * Retrieves the notification display name for the invitee.
106
+     *
107
+     * @param {Object} invitee - The invitee object.
108
+     * @returns {string}
109
+     */
110
+    _getDisplayName(invitee) {
111
+        if (invitee.type === INVITE_TYPES.PHONE) {
112
+            return invitee.number;
113
+        }
114
+
115
+        if (invitee.type === INVITE_TYPES.SIP) {
116
+            return invitee.address;
117
+        }
118
+
119
+        return invitee.name;
120
+    }
121
+
103
     /**
122
     /**
104
      * Invite people and numbers to the conference. The logic works by inviting
123
      * Invite people and numbers to the conference. The logic works by inviting
105
      * numbers, people/rooms, sip endpoints and videosipgw in parallel. All invitees are
124
      * numbers, people/rooms, sip endpoints and videosipgw in parallel. All invitees are
160
                     if (invitedCount >= 3) {
179
                     if (invitedCount >= 3) {
161
                         notificationProps = {
180
                         notificationProps = {
162
                             titleArguments: {
181
                             titleArguments: {
163
-                                name: invitees[0].name || invitees[0].address,
182
+                                name: this._getDisplayName(invitees[0]),
164
                                 count: invitedCount - 1
183
                                 count: invitedCount - 1
165
                             },
184
                             },
166
                             titleKey: 'notify.invitedThreePlusMembers'
185
                             titleKey: 'notify.invitedThreePlusMembers'
168
                     } else if (invitedCount === 2) {
187
                     } else if (invitedCount === 2) {
169
                         notificationProps = {
188
                         notificationProps = {
170
                             titleArguments: {
189
                             titleArguments: {
171
-                                first: invitees[0].name || invitees[0].address,
172
-                                second: invitees[1].name || invitees[1].address
190
+                                first: this._getDisplayName(invitees[0]),
191
+                                second: this._getDisplayName(invitees[1])
173
                             },
192
                             },
174
                             titleKey: 'notify.invitedTwoMembers'
193
                             titleKey: 'notify.invitedTwoMembers'
175
                         };
194
                         };
176
                     } else if (invitedCount) {
195
                     } else if (invitedCount) {
177
                         notificationProps = {
196
                         notificationProps = {
178
                             titleArguments: {
197
                             titleArguments: {
179
-                                name: invitees[0].name || invitees[0].address
198
+                                name: this._getDisplayName(invitees[0])
180
                             },
199
                             },
181
                             titleKey: 'notify.invitedOneMember'
200
                             titleKey: 'notify.invitedOneMember'
182
                         };
201
                         };

+ 7
- 7
react/features/invite/components/add-people-dialog/native/AddPeopleDialog.js 查看文件

31
 } from '../../../../base/react';
31
 } from '../../../../base/react';
32
 import { connect } from '../../../../base/redux';
32
 import { connect } from '../../../../base/redux';
33
 import { beginShareRoom } from '../../../../share-room';
33
 import { beginShareRoom } from '../../../../share-room';
34
-import { ADD_PEOPLE_DIALOG_VIEW_ID } from '../../../constants';
34
+import { ADD_PEOPLE_DIALOG_VIEW_ID, INVITE_TYPES } from '../../../constants';
35
 import AbstractAddPeopleDialog, {
35
 import AbstractAddPeopleDialog, {
36
     type Props as AbstractProps,
36
     type Props as AbstractProps,
37
     type State as AbstractState,
37
     type State as AbstractState,
242
         const { item } = flatListItem;
242
         const { item } = flatListItem;
243
 
243
 
244
         switch (item.type) {
244
         switch (item.type) {
245
-        case 'phone':
245
+        case INVITE_TYPES.PHONE:
246
             return {
246
             return {
247
                 avatar: IconPhone,
247
                 avatar: IconPhone,
248
                 key: item.number,
248
                 key: item.number,
249
                 title: item.number
249
                 title: item.number
250
             };
250
             };
251
-        case 'user':
251
+        case INVITE_TYPES.USER:
252
             return {
252
             return {
253
                 avatar: item.avatar,
253
                 avatar: item.avatar,
254
                 key: item.id || item.user_id,
254
                 key: item.id || item.user_id,
273
      * @returns {string}
273
      * @returns {string}
274
      */
274
      */
275
     _keyExtractor(item) {
275
     _keyExtractor(item) {
276
-        return item.type === 'user' ? item.id || item.user_id : item.number;
276
+        return item.type === INVITE_TYPES.USER ? item.id || item.user_id : item.number;
277
     }
277
     }
278
 
278
 
279
     _onClearField: () => void
279
     _onClearField: () => void
340
     _onPressItem(item) {
340
     _onPressItem(item) {
341
         return () => {
341
         return () => {
342
             const { inviteItems } = this.state;
342
             const { inviteItems } = this.state;
343
-            const finderKey = item.type === 'phone' ? 'number' : 'user_id';
343
+            const finderKey = item.type === INVITE_TYPES.PHONE ? 'number' : 'user_id';
344
 
344
 
345
             if (inviteItems.find(
345
             if (inviteItems.find(
346
                     _.matchesProperty(finderKey, item[finderKey]))) {
346
                     _.matchesProperty(finderKey, item[finderKey]))) {
504
         }
504
         }
505
 
505
 
506
         switch (item.type) {
506
         switch (item.type) {
507
-        case 'phone':
507
+        case INVITE_TYPES.PHONE:
508
             selected = inviteItems.find(_.matchesProperty('number', item.number));
508
             selected = inviteItems.find(_.matchesProperty('number', item.number));
509
             break;
509
             break;
510
-        case 'user':
510
+        case INVITE_TYPES.USER:
511
             selected = item.id
511
             selected = item.id
512
                 ? inviteItems.find(_.matchesProperty('id', item.id))
512
                 ? inviteItems.find(_.matchesProperty('id', item.id))
513
                 : inviteItems.find(_.matchesProperty('user_id', item.user_id));
513
                 : inviteItems.find(_.matchesProperty('user_id', item.user_id));

+ 6
- 5
react/features/invite/components/add-people-dialog/web/InviteContactsForm.js 查看文件

12
 import { connect } from '../../../../base/redux';
12
 import { connect } from '../../../../base/redux';
13
 import { isVpaasMeeting } from '../../../../billing-counter/functions';
13
 import { isVpaasMeeting } from '../../../../billing-counter/functions';
14
 import { hideAddPeopleDialog } from '../../../actions';
14
 import { hideAddPeopleDialog } from '../../../actions';
15
+import { INVITE_TYPES } from '../../../constants';
15
 import AbstractAddPeopleDialog, {
16
 import AbstractAddPeopleDialog, {
16
     type Props as AbstractProps,
17
     type Props as AbstractProps,
17
     type State,
18
     type State,
181
      * @returns {Object} The item to display as selected in the input.
182
      * @returns {Object} The item to display as selected in the input.
182
      */
183
      */
183
     _onItemSelected(item) {
184
     _onItemSelected(item) {
184
-        if (item.item.type === 'phone') {
185
+        if (item.item.type === INVITE_TYPES.PHONE) {
185
             item.content = item.item.number;
186
             item.content = item.item.number;
186
         }
187
         }
187
 
188
 
285
      */
286
      */
286
     _parseQueryResults(response = []) {
287
     _parseQueryResults(response = []) {
287
         const { t, _dialOutEnabled } = this.props;
288
         const { t, _dialOutEnabled } = this.props;
288
-        const users = response.filter(item => item.type !== 'phone' && item.type !== 'sip');
289
+        const users = response.filter(item => item.type === INVITE_TYPES.USER);
289
         const userDisplayItems = [];
290
         const userDisplayItems = [];
290
 
291
 
291
         for (const user of users) {
292
         for (const user of users) {
309
                     content: `${phone} (${name})`,
310
                     content: `${phone} (${name})`,
310
                     elemBefore: elemAvatar,
311
                     elemBefore: elemAvatar,
311
                     item: {
312
                     item: {
312
-                        type: 'phone',
313
+                        type: INVITE_TYPES.PHONE,
313
                         number: phone
314
                         number: phone
314
                     },
315
                     },
315
                     tag: {
316
                     tag: {
320
             }
321
             }
321
         }
322
         }
322
 
323
 
323
-        const numbers = response.filter(item => item.type === 'phone');
324
+        const numbers = response.filter(item => item.type === INVITE_TYPES.PHONE);
324
         const telephoneIcon = this._renderTelephoneIcon();
325
         const telephoneIcon = this._renderTelephoneIcon();
325
 
326
 
326
         const numberDisplayItems = numbers.map(number => {
327
         const numberDisplayItems = numbers.map(number => {
349
         });
350
         });
350
 
351
 
351
 
352
 
352
-        const sipAddresses = response.filter(item => item.type === 'sip');
353
+        const sipAddresses = response.filter(item => item.type === INVITE_TYPES.SIP);
353
 
354
 
354
         const sipDisplayItems = sipAddresses.map(sip => {
355
         const sipDisplayItems = sipAddresses.map(sip => {
355
             return {
356
             return {

+ 11
- 0
react/features/invite/constants.js 查看文件

48
  */
48
  */
49
 // eslint-disable-next-line max-len
49
 // eslint-disable-next-line max-len
50
 export const SIP_ADDRESS_REGEX = /^[a-zA-Z]+(?:([^\s>:@]+)(?::([^\s@>]+))?@)?([\w\-.]+)(?::(\d+))?((?:;[^\s=?>;]+(?:=[^\s?;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;
50
 export const SIP_ADDRESS_REGEX = /^[a-zA-Z]+(?:([^\s>:@]+)(?::([^\s@>]+))?@)?([\w\-.]+)(?::(\d+))?((?:;[^\s=?>;]+(?:=[^\s?;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;
51
+
52
+/**
53
+ * Different invite types mapping
54
+ */
55
+export const INVITE_TYPES = {
56
+    PHONE: 'phone',
57
+    ROOM: 'room',
58
+    SIP: 'sip',
59
+    USER: 'user',
60
+    VIDEO_ROOM: 'videosipgw'
61
+};

+ 4
- 4
react/features/invite/functions.js 查看文件

10
 import { doGetJSON, parseURIString } from '../base/util';
10
 import { doGetJSON, parseURIString } from '../base/util';
11
 import { isVpaasMeeting } from '../billing-counter/functions';
11
 import { isVpaasMeeting } from '../billing-counter/functions';
12
 
12
 
13
-import { SIP_ADDRESS_REGEX } from './constants';
13
+import { INVITE_TYPES, SIP_ADDRESS_REGEX } from './constants';
14
 import logger from './logger';
14
 import logger from './logger';
15
 
15
 
16
 declare var $: Function;
16
 declare var $: Function;
227
              * the phone number can then be cleaned up when convenient.
227
              * the phone number can then be cleaned up when convenient.
228
              */
228
              */
229
             const hasPhoneResult
229
             const hasPhoneResult
230
-                = peopleResults.find(result => result.type === 'phone');
230
+                = peopleResults.find(result => result.type === INVITE_TYPES.PHONE);
231
 
231
 
232
             if (!hasPhoneResult && typeof phoneResults.allow === 'boolean') {
232
             if (!hasPhoneResult && typeof phoneResults.allow === 'boolean') {
233
                 results.push({
233
                 results.push({
234
                     allowed: phoneResults.allow,
234
                     allowed: phoneResults.allow,
235
                     country: phoneResults.country,
235
                     country: phoneResults.country,
236
-                    type: 'phone',
236
+                    type: INVITE_TYPES.PHONE,
237
                     number: phoneResults.phone,
237
                     number: phoneResults.phone,
238
                     originalEntry: text,
238
                     originalEntry: text,
239
                     showCountryCodeReminder: !hasCountryCode
239
                     showCountryCodeReminder: !hasCountryCode
242
 
242
 
243
             if (sipInviteEnabled && isASipAddress(text)) {
243
             if (sipInviteEnabled && isASipAddress(text)) {
244
                 results.push({
244
                 results.push({
245
-                    type: 'sip',
245
+                    type: INVITE_TYPES.SIP,
246
                     address: text
246
                     address: text
247
                 });
247
                 });
248
             }
248
             }

正在加载...
取消
保存