Преглед изворни кода

fix(invite): allow arbitrary strings if no dialOutAuthUrl

j8
Leonard Kim пре 6 година
родитељ
комит
0cf585860b
2 измењених фајлова са 21 додато и 15 уклоњено
  1. 1
    2
      react/features/invite/actions.js
  2. 20
    13
      react/features/invite/functions.js

+ 1
- 2
react/features/invite/actions.js Прегледај датотеку

@@ -11,7 +11,6 @@ import {
11 11
 import {
12 12
     getDialInConferenceID,
13 13
     getDialInNumbers,
14
-    getDigitsOnly,
15 14
     invitePeopleAndChatRooms
16 15
 } from './functions';
17 16
 
@@ -65,7 +64,7 @@ export function invite(invitees: Array<Object>) {
65 64
             // For each number, dial out. On success, remove the number from
66 65
             // {@link invitesLeftToSend}.
67 66
             const phoneInvitePromises = phoneNumbers.map(item => {
68
-                const numberToInvite = getDigitsOnly(item.number);
67
+                const numberToInvite = item.number;
69 68
 
70 69
                 return conference.dial(numberToInvite)
71 70
                     .then(() => {

+ 20
- 13
react/features/invite/functions.js Прегледај датотеку

@@ -20,17 +20,6 @@ export function checkDialNumber(
20 20
         dialNumber: string,
21 21
         dialOutAuthUrl: string
22 22
 ): Promise<Object> {
23
-
24
-    if (!dialOutAuthUrl) {
25
-        // no auth url, let's say it is valid
26
-        const response = {
27
-            allow: true,
28
-            phone: `+${dialNumber}`
29
-        };
30
-
31
-        return Promise.resolve(response);
32
-    }
33
-
34 23
     const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
35 24
 
36 25
     return new Promise((resolve, reject) => {
@@ -159,10 +148,18 @@ export function getInviteResultsForQuery(
159 148
     }
160 149
 
161 150
 
162
-    const hasCountryCode = text.startsWith('+');
151
+    let hasCountryCode = text.startsWith('+');
163 152
     let phoneNumberPromise;
164 153
 
165
-    if (dialOutEnabled && isMaybeAPhoneNumber(text)) {
154
+    // Phone numbers are handled a specially to enable both cases of restricting
155
+    // numbers to telephone number-y numbers and accepting any arbitrary string,
156
+    // which may be valid for SIP (jigasi) calls. If the dialOutAuthUrl is
157
+    // defined, then it is assumed the call is to a telephone number and
158
+    // some validation of the number is completed, with the + sign used as a way
159
+    // for the UI to detect and enforce the usage of a country code. If the
160
+    // dialOutAuthUrl is not defined, accept anything because this is assumed
161
+    // to be the SIP (jigasi) case.
162
+    if (dialOutEnabled && dialOutAuthUrl && isMaybeAPhoneNumber(text)) {
166 163
         let numberToVerify = text;
167 164
 
168 165
         // When the number to verify does not start with a +, we assume no
@@ -178,6 +175,16 @@ export function getInviteResultsForQuery(
178 175
         numberToVerify = getDigitsOnly(numberToVerify);
179 176
 
180 177
         phoneNumberPromise = checkDialNumber(numberToVerify, dialOutAuthUrl);
178
+    } else if (dialOutEnabled && !dialOutAuthUrl) {
179
+        // fake having a country code to hide the country code reminder
180
+        hasCountryCode = true;
181
+
182
+        // With no auth url, let's say the text is a valid number
183
+        phoneNumberPromise = Promise.resolve({
184
+            allow: true,
185
+            country: '',
186
+            phone: text
187
+        });
181 188
     } else {
182 189
         phoneNumberPromise = Promise.resolve({});
183 190
     }

Loading…
Откажи
Сачувај