|
@@ -10,6 +10,7 @@ import { toState } from '../base/redux';
|
10
|
10
|
import { doGetJSON, parseURIString } from '../base/util';
|
11
|
11
|
import { isVpaasMeeting } from '../billing-counter/functions';
|
12
|
12
|
|
|
13
|
+import { SIP_ADDRESS_REGEX } from './constants';
|
13
|
14
|
import logger from './logger';
|
14
|
15
|
|
15
|
16
|
declare var $: Function;
|
|
@@ -122,6 +123,11 @@ export type GetInviteResultsOptions = {
|
122
|
123
|
*/
|
123
|
124
|
peopleSearchUrl: string,
|
124
|
125
|
|
|
126
|
+ /**
|
|
127
|
+ * Whether or not to check sip invites.
|
|
128
|
+ */
|
|
129
|
+ sipInviteEnabled: boolean,
|
|
130
|
+
|
125
|
131
|
/**
|
126
|
132
|
* The jwt token to pass to the search service.
|
127
|
133
|
*/
|
|
@@ -149,6 +155,7 @@ export function getInviteResultsForQuery(
|
149
|
155
|
dialOutEnabled,
|
150
|
156
|
peopleSearchQueryTypes,
|
151
|
157
|
peopleSearchUrl,
|
|
158
|
+ sipInviteEnabled,
|
152
|
159
|
jwt
|
153
|
160
|
} = options;
|
154
|
161
|
|
|
@@ -233,6 +240,13 @@ export function getInviteResultsForQuery(
|
233
|
240
|
});
|
234
|
241
|
}
|
235
|
242
|
|
|
243
|
+ if (sipInviteEnabled && isASipAddress(text)) {
|
|
244
|
+ results.push({
|
|
245
|
+ type: 'sip',
|
|
246
|
+ address: text
|
|
247
|
+ });
|
|
248
|
+ }
|
|
249
|
+
|
236
|
250
|
return results;
|
237
|
251
|
});
|
238
|
252
|
}
|
|
@@ -374,6 +388,21 @@ export function isDialOutEnabled(state: Object): boolean {
|
374
|
388
|
&& conference && conference.isSIPCallingSupported();
|
375
|
389
|
}
|
376
|
390
|
|
|
391
|
+/**
|
|
392
|
+ * Determines if inviting sip endpoints is enabled or not.
|
|
393
|
+ *
|
|
394
|
+ * @param {Object} state - Current state.
|
|
395
|
+ * @returns {boolean} Indication of whether dial out is currently enabled.
|
|
396
|
+ */
|
|
397
|
+export function isSipInviteEnabled(state: Object): boolean {
|
|
398
|
+ const { sipInviteUrl } = state['features/base/config'];
|
|
399
|
+ const { features = {} } = getLocalParticipant(state);
|
|
400
|
+
|
|
401
|
+ return state['features/base/jwt'].jwt
|
|
402
|
+ && Boolean(sipInviteUrl)
|
|
403
|
+ && String(features['sip-outbound-call']) === 'true';
|
|
404
|
+}
|
|
405
|
+
|
377
|
406
|
/**
|
378
|
407
|
* Checks whether a string looks like it could be for a phone number.
|
379
|
408
|
*
|
|
@@ -392,6 +421,16 @@ function isMaybeAPhoneNumber(text: string): boolean {
|
392
|
421
|
return Boolean(digits.length);
|
393
|
422
|
}
|
394
|
423
|
|
|
424
|
+/**
|
|
425
|
+ * Checks whether a string matches a sip address format.
|
|
426
|
+ *
|
|
427
|
+ * @param {string} text - The text to check.
|
|
428
|
+ * @returns {boolean} True if provided text matches a sip address format.
|
|
429
|
+ */
|
|
430
|
+function isASipAddress(text: string): boolean {
|
|
431
|
+ return SIP_ADDRESS_REGEX.test(text);
|
|
432
|
+}
|
|
433
|
+
|
395
|
434
|
/**
|
396
|
435
|
* RegExp to use to determine if some text might be a phone number.
|
397
|
436
|
*
|
|
@@ -764,3 +803,47 @@ export function isSharingEnabled(sharingFeature: string) {
|
764
|
803
|
|| typeof interfaceConfig.SHARING_FEATURES === 'undefined'
|
765
|
804
|
|| (interfaceConfig.SHARING_FEATURES.length && interfaceConfig.SHARING_FEATURES.indexOf(sharingFeature) > -1);
|
766
|
805
|
}
|
|
806
|
+
|
|
807
|
+/**
|
|
808
|
+ * Sends a post request to an invite service.
|
|
809
|
+ *
|
|
810
|
+ * @param {Array} inviteItems - The list of the "sip" type items to invite.
|
|
811
|
+ * @param {string} sipInviteUrl - The invite service that generates the invitation.
|
|
812
|
+ * @param {string} jwt - The jwt token.
|
|
813
|
+ * @param {string} roomName - The name to the conference.
|
|
814
|
+ * @param {string} displayName - The user display name.
|
|
815
|
+ * @returns {Promise} - The promise created by the request.
|
|
816
|
+ */
|
|
817
|
+export function inviteSipEndpoints( // eslint-disable-line max-params
|
|
818
|
+ inviteItems: Array<Object>,
|
|
819
|
+ sipInviteUrl: string,
|
|
820
|
+ jwt: string,
|
|
821
|
+ roomName: string,
|
|
822
|
+ displayName: string
|
|
823
|
+): Promise<void> {
|
|
824
|
+ if (inviteItems.length === 0) {
|
|
825
|
+ return Promise.resolve();
|
|
826
|
+ }
|
|
827
|
+
|
|
828
|
+ return fetch(
|
|
829
|
+ `${sipInviteUrl}?token=${jwt}`,
|
|
830
|
+ {
|
|
831
|
+ body: JSON.stringify({
|
|
832
|
+ callParams: {
|
|
833
|
+ callUrlInfo: {
|
|
834
|
+ baseUrl: window.location.origin,
|
|
835
|
+ callName: roomName
|
|
836
|
+ }
|
|
837
|
+ },
|
|
838
|
+ sipClientParams: {
|
|
839
|
+ displayName,
|
|
840
|
+ sipAddress: inviteItems.map(item => item.address)
|
|
841
|
+ }
|
|
842
|
+ }),
|
|
843
|
+ method: 'POST',
|
|
844
|
+ headers: {
|
|
845
|
+ 'Content-Type': 'application/json'
|
|
846
|
+ }
|
|
847
|
+ }
|
|
848
|
+ );
|
|
849
|
+}
|