|
@@ -76,9 +76,8 @@ export function getDialInNumbers(url: string): Promise<*> {
|
76
|
76
|
/**
|
77
|
77
|
* Removes all non-numeric characters from a string.
|
78
|
78
|
*
|
79
|
|
- * @param {string} text - The string from which to remove all characters
|
80
|
|
- * except numbers.
|
81
|
|
- * @private
|
|
79
|
+ * @param {string} text - The string from which to remove all characters except
|
|
80
|
+ * numbers.
|
82
|
81
|
* @returns {string} A string with only numbers.
|
83
|
82
|
*/
|
84
|
83
|
export function getDigitsOnly(text: string = ''): string {
|
|
@@ -126,8 +125,8 @@ export type GetInviteResultsOptions = {
|
126
|
125
|
* Combines directory search with phone number validation to produce a single
|
127
|
126
|
* set of invite search results.
|
128
|
127
|
*
|
129
|
|
- * @param {string} query - Text to search.
|
130
|
|
- * @param {GetInviteResultsOptions} options - Options to use when searching.
|
|
128
|
+ * @param {string} query - Text to search.
|
|
129
|
+ * @param {GetInviteResultsOptions} options - Options to use when searching.
|
131
|
130
|
* @returns {Promise<*>}
|
132
|
131
|
*/
|
133
|
132
|
export function getInviteResultsForQuery(
|
|
@@ -166,19 +165,18 @@ export function getInviteResultsForQuery(
|
166
|
165
|
let numberToVerify = text;
|
167
|
166
|
|
168
|
167
|
// When the number to verify does not start with a +, we assume no
|
169
|
|
- // proper country code has been entered. In such a case, prepend 1
|
170
|
|
- // for the country code. The service currently takes care of
|
171
|
|
- // prepending the +.
|
|
168
|
+ // proper country code has been entered. In such a case, prepend 1 for
|
|
169
|
+ // the country code. The service currently takes care of prepending the
|
|
170
|
+ // +.
|
172
|
171
|
if (!hasCountryCode && !text.startsWith('1')) {
|
173
|
172
|
numberToVerify = `1${numberToVerify}`;
|
174
|
173
|
}
|
175
|
174
|
|
176
|
|
- // The validation service works properly when the query is digits
|
177
|
|
- // only so ensure only digits get sent.
|
|
175
|
+ // The validation service works properly when the query is digits only
|
|
176
|
+ // so ensure only digits get sent.
|
178
|
177
|
numberToVerify = getDigitsOnly(numberToVerify);
|
179
|
178
|
|
180
|
|
- phoneNumberPromise
|
181
|
|
- = checkDialNumber(numberToVerify, dialOutAuthUrl);
|
|
179
|
+ phoneNumberPromise = checkDialNumber(numberToVerify, dialOutAuthUrl);
|
182
|
180
|
} else {
|
183
|
181
|
phoneNumberPromise = Promise.resolve({});
|
184
|
182
|
}
|
|
@@ -190,18 +188,16 @@ export function getInviteResultsForQuery(
|
190
|
188
|
];
|
191
|
189
|
|
192
|
190
|
/**
|
193
|
|
- * This check for phone results is for the day the call to
|
194
|
|
- * searching people might return phone results as well. When
|
195
|
|
- * that day comes this check will make it so the server checks
|
196
|
|
- * are honored and the local appending of the number is not
|
197
|
|
- * done. The local appending of the phone number can then be
|
198
|
|
- * cleaned up when convenient.
|
|
191
|
+ * This check for phone results is for the day the call to searching
|
|
192
|
+ * people might return phone results as well. When that day comes
|
|
193
|
+ * this check will make it so the server checks are honored and the
|
|
194
|
+ * local appending of the number is not done. The local appending of
|
|
195
|
+ * the phone number can then be cleaned up when convenient.
|
199
|
196
|
*/
|
200
|
|
- const hasPhoneResult = peopleResults.find(
|
201
|
|
- result => result.type === 'phone');
|
|
197
|
+ const hasPhoneResult
|
|
198
|
+ = peopleResults.find(result => result.type === 'phone');
|
202
|
199
|
|
203
|
|
- if (!hasPhoneResult
|
204
|
|
- && typeof phoneResults.allow === 'boolean') {
|
|
200
|
+ if (!hasPhoneResult && typeof phoneResults.allow === 'boolean') {
|
205
|
201
|
results.push({
|
206
|
202
|
allowed: phoneResults.allow,
|
207
|
203
|
country: phoneResults.country,
|
|
@@ -216,6 +212,28 @@ export function getInviteResultsForQuery(
|
216
|
212
|
});
|
217
|
213
|
}
|
218
|
214
|
|
|
215
|
+/**
|
|
216
|
+ * Helper for determining how many of each type of user is being invited. Used
|
|
217
|
+ * for logging and sending analytics related to invites.
|
|
218
|
+ *
|
|
219
|
+ * @param {Array} inviteItems - An array with the invite items, as created in
|
|
220
|
+ * {@link _parseQueryResults}.
|
|
221
|
+ * @returns {Object} An object with keys as user types and values as the number
|
|
222
|
+ * of invites for that type.
|
|
223
|
+ */
|
|
224
|
+export function getInviteTypeCounts(inviteItems: Array<Object> = []) {
|
|
225
|
+ const inviteTypeCounts = {};
|
|
226
|
+
|
|
227
|
+ inviteItems.forEach(({ type }) => {
|
|
228
|
+ if (!inviteTypeCounts[type]) {
|
|
229
|
+ inviteTypeCounts[type] = 0;
|
|
230
|
+ }
|
|
231
|
+ inviteTypeCounts[type]++;
|
|
232
|
+ });
|
|
233
|
+
|
|
234
|
+ return inviteTypeCounts;
|
|
235
|
+}
|
|
236
|
+
|
219
|
237
|
/**
|
220
|
238
|
* Sends a post request to an invite service.
|
221
|
239
|
*
|
|
@@ -223,8 +241,8 @@ export function getInviteResultsForQuery(
|
223
|
241
|
* invitation.
|
224
|
242
|
* @param {string} inviteUrl - The url to the conference.
|
225
|
243
|
* @param {string} jwt - The jwt token to pass to the search service.
|
226
|
|
- * @param {Immutable.List} inviteItems - The list of the "user" or "room"
|
227
|
|
- * type items to invite.
|
|
244
|
+ * @param {Immutable.List} inviteItems - The list of the "user" or "room" type
|
|
245
|
+ * items to invite.
|
228
|
246
|
* @returns {Promise} - The promise created by the request.
|
229
|
247
|
*/
|
230
|
248
|
export function invitePeopleAndChatRooms( // eslint-disable-line max-params
|
|
@@ -282,24 +300,37 @@ export function isAddPeopleEnabled(state: Object): boolean {
|
282
|
300
|
* @returns {boolean} Indication of whether dial out is currently enabled.
|
283
|
301
|
*/
|
284
|
302
|
export function isDialOutEnabled(state: Object): boolean {
|
|
303
|
+ const participant = getLocalParticipant(state);
|
285
|
304
|
const { conference } = state['features/base/conference'];
|
286
|
305
|
const { isGuest } = state['features/base/jwt'];
|
287
|
306
|
const { enableUserRolesBasedOnToken } = state['features/base/config'];
|
288
|
|
- const participant = getLocalParticipant(state);
|
|
307
|
+ let dialOutEnabled
|
|
308
|
+ = participant && participant.role === PARTICIPANT_ROLE.MODERATOR
|
|
309
|
+ && conference && conference.isSIPCallingSupported()
|
|
310
|
+ && (!enableUserRolesBasedOnToken || !isGuest);
|
|
311
|
+
|
|
312
|
+ if (dialOutEnabled) {
|
|
313
|
+ // XXX The mobile/react-native app is capable of disabling of dial-out.
|
|
314
|
+ // Anyway, the Web/React app does not have that capability so default
|
|
315
|
+ // appropriately.
|
|
316
|
+ const { app } = state['features/app'];
|
|
317
|
+
|
|
318
|
+ dialOutEnabled = app && app.props.dialoOutEnabled;
|
|
319
|
+
|
|
320
|
+ return (
|
|
321
|
+ (typeof dialOutEnabled === 'undefined') || Boolean(dialOutEnabled));
|
|
322
|
+ }
|
289
|
323
|
|
290
|
|
- return participant && participant.role === PARTICIPANT_ROLE.MODERATOR
|
291
|
|
- && conference && conference.isSIPCallingSupported()
|
292
|
|
- && (!enableUserRolesBasedOnToken || !isGuest);
|
|
324
|
+ return false;
|
293
|
325
|
}
|
294
|
326
|
|
295
|
327
|
/**
|
296
|
328
|
* Checks whether a string looks like it could be for a phone number.
|
297
|
329
|
*
|
298
|
|
- * @param {string} text - The text to check whether or not it could be a
|
299
|
|
- * phone number.
|
300
|
|
- * @private
|
301
|
|
- * @returns {boolean} True if the string looks like it could be a phone
|
|
330
|
+ * @param {string} text - The text to check whether or not it could be a phone
|
302
|
331
|
* number.
|
|
332
|
+ * @private
|
|
333
|
+ * @returns {boolean} True if the string looks like it could be a phone number.
|
303
|
334
|
*/
|
304
|
335
|
function isMaybeAPhoneNumber(text: string): boolean {
|
305
|
336
|
if (!isPhoneNumberRegex().test(text)) {
|
|
@@ -365,28 +396,3 @@ export function searchDirectory( // eslint-disable-line max-params
|
365
|
396
|
return Promise.reject(error);
|
366
|
397
|
});
|
367
|
398
|
}
|
368
|
|
-
|
369
|
|
-/**
|
370
|
|
- * Helper for determining how many of each type of user is being invited.
|
371
|
|
- * Used for logging and sending analytics related to invites.
|
372
|
|
- *
|
373
|
|
- * @param {Array} inviteItems - An array with the invite items, as created
|
374
|
|
- * in {@link _parseQueryResults}.
|
375
|
|
- * @private
|
376
|
|
- * @returns {Object} An object with keys as user types and values as the
|
377
|
|
- * number of invites for that type.
|
378
|
|
- */
|
379
|
|
-export function getInviteTypeCounts(inviteItems: Array<Object> = []) {
|
380
|
|
- const inviteTypeCounts = {};
|
381
|
|
-
|
382
|
|
- inviteItems.forEach(({ type }) => {
|
383
|
|
-
|
384
|
|
- if (!inviteTypeCounts[type]) {
|
385
|
|
- inviteTypeCounts[type] = 0;
|
386
|
|
- }
|
387
|
|
-
|
388
|
|
- inviteTypeCounts[type]++;
|
389
|
|
- });
|
390
|
|
-
|
391
|
|
- return inviteTypeCounts;
|
392
|
|
-}
|