|
@@ -1,8 +1,44 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
|
3
|
+import { doGetJSON } from '../base/util';
|
|
4
|
+
|
3
|
5
|
declare var $: Function;
|
4
|
6
|
declare var interfaceConfig: Object;
|
5
|
7
|
|
|
8
|
+const logger = require('jitsi-meet-logger').getLogger(__filename);
|
|
9
|
+
|
|
10
|
+/**
|
|
11
|
+ * Sends a GET request to obtain the conference ID necessary for identifying
|
|
12
|
+ * which conference to join after diaing the dial-in service.
|
|
13
|
+ *
|
|
14
|
+ * @param {string} baseUrl - The url for obtaining the conference ID (pin) for
|
|
15
|
+ * dialing into a conference.
|
|
16
|
+ * @param {string} roomName - The conference name to find the associated
|
|
17
|
+ * conference ID.
|
|
18
|
+ * @param {string} mucURL - In which MUC the conference exists.
|
|
19
|
+ * @returns {Promise} - The promise created by the request.
|
|
20
|
+ */
|
|
21
|
+export function getDialInConferenceID(
|
|
22
|
+ baseUrl: string,
|
|
23
|
+ roomName: string,
|
|
24
|
+ mucURL: string): Promise<Object> {
|
|
25
|
+ const conferenceIDURL = `${baseUrl}?conference=${roomName}@${mucURL}`;
|
|
26
|
+
|
|
27
|
+ return doGetJSON(conferenceIDURL);
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+/**
|
|
31
|
+ * Sends a GET request for phone numbers used to dial into a conference.
|
|
32
|
+ *
|
|
33
|
+ * @param {string} url - The service that returns confernce dial-in numbers.
|
|
34
|
+ * @returns {Promise} - The promise created by the request. The returned numbers
|
|
35
|
+ * may be an array of numbers or an object with countries as keys and arrays of
|
|
36
|
+ * phone number strings.
|
|
37
|
+ */
|
|
38
|
+export function getDialInNumbers(url: string): Promise<*> {
|
|
39
|
+ return doGetJSON(url);
|
|
40
|
+}
|
|
41
|
+
|
6
|
42
|
/**
|
7
|
43
|
* Get the position of the invite option in the interfaceConfig.INVITE_OPTIONS
|
8
|
44
|
* list.
|
|
@@ -78,13 +114,24 @@ export function searchDirectory( // eslint-disable-line max-params
|
78
|
114
|
): Promise<Array<Object>> {
|
79
|
115
|
const queryTypesString = JSON.stringify(queryTypes);
|
80
|
116
|
|
81
|
|
- return new Promise((resolve, reject) => {
|
82
|
|
- $.getJSON(
|
83
|
|
- `${serviceUrl}?query=${encodeURIComponent(text)}&queryTypes=${
|
84
|
|
- queryTypesString}&jwt=${jwt}`,
|
85
|
|
- resolve)
|
86
|
|
- .catch((jqxhr, textStatus, error) => reject(error));
|
87
|
|
- });
|
|
117
|
+ return fetch(`${serviceUrl}?query=${encodeURIComponent(text)}&queryTypes=${
|
|
118
|
+ queryTypesString}&jwt=${jwt}`)
|
|
119
|
+ .then(response => {
|
|
120
|
+ const jsonify = response.json();
|
|
121
|
+
|
|
122
|
+ if (response.ok) {
|
|
123
|
+ return jsonify;
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ return jsonify
|
|
127
|
+ .then(result => Promise.reject(result));
|
|
128
|
+ })
|
|
129
|
+ .catch(error => {
|
|
130
|
+ logger.error(
|
|
131
|
+ 'Error searching directory:', error);
|
|
132
|
+
|
|
133
|
+ return Promise.reject(error);
|
|
134
|
+ });
|
88
|
135
|
}
|
89
|
136
|
|
90
|
137
|
/**
|