您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // @flow
  2. import { i18next } from '../base/i18n';
  3. import { isLocalParticipantModerator } from '../base/participants';
  4. import { toState } from '../base/redux';
  5. import { doGetJSON, parseURIString } from '../base/util';
  6. import logger from './logger';
  7. declare var $: Function;
  8. declare var interfaceConfig: Object;
  9. /**
  10. * Sends an ajax request to check if the phone number can be called.
  11. *
  12. * @param {string} dialNumber - The dial number to check for validity.
  13. * @param {string} dialOutAuthUrl - The endpoint to use for checking validity.
  14. * @returns {Promise} - The promise created by the request.
  15. */
  16. export function checkDialNumber(
  17. dialNumber: string,
  18. dialOutAuthUrl: string
  19. ): Promise<Object> {
  20. const fullUrl = `${dialOutAuthUrl}?phone=${dialNumber}`;
  21. return new Promise((resolve, reject) => {
  22. $.getJSON(fullUrl)
  23. .then(resolve)
  24. .catch(reject);
  25. });
  26. }
  27. /**
  28. * Sends a GET request to obtain the conference ID necessary for identifying
  29. * which conference to join after diaing the dial-in service.
  30. *
  31. * @param {string} baseUrl - The url for obtaining the conference ID (pin) for
  32. * dialing into a conference.
  33. * @param {string} roomName - The conference name to find the associated
  34. * conference ID.
  35. * @param {string} mucURL - In which MUC the conference exists.
  36. * @returns {Promise} - The promise created by the request.
  37. */
  38. export function getDialInConferenceID(
  39. baseUrl: string,
  40. roomName: string,
  41. mucURL: string
  42. ): Promise<Object> {
  43. const conferenceIDURL = `${baseUrl}?conference=${roomName}@${mucURL}`;
  44. return doGetJSON(conferenceIDURL, true);
  45. }
  46. /**
  47. * Sends a GET request for phone numbers used to dial into a conference.
  48. *
  49. * @param {string} url - The service that returns conference dial-in numbers.
  50. * @param {string} roomName - The conference name to find the associated
  51. * conference ID.
  52. * @param {string} mucURL - In which MUC the conference exists.
  53. * @returns {Promise} - The promise created by the request. The returned numbers
  54. * may be an array of Objects containing numbers, with keys countryCode,
  55. * tollFree, formattedNumber or an object with countries as keys and arrays of
  56. * phone number strings, as the second one should not be used and is deprecated.
  57. */
  58. export function getDialInNumbers(
  59. url: string,
  60. roomName: string,
  61. mucURL: string
  62. ): Promise<*> {
  63. const fullUrl = `${url}?conference=${roomName}@${mucURL}`;
  64. return doGetJSON(fullUrl, true);
  65. }
  66. /**
  67. * Removes all non-numeric characters from a string.
  68. *
  69. * @param {string} text - The string from which to remove all characters except
  70. * numbers.
  71. * @returns {string} A string with only numbers.
  72. */
  73. export function getDigitsOnly(text: string = ''): string {
  74. return text.replace(/\D/g, '');
  75. }
  76. /**
  77. * Type of the options to use when sending a search query.
  78. */
  79. export type GetInviteResultsOptions = {
  80. /**
  81. * The endpoint to use for checking phone number validity.
  82. */
  83. dialOutAuthUrl: string,
  84. /**
  85. * Whether or not to search for people.
  86. */
  87. addPeopleEnabled: boolean,
  88. /**
  89. * Whether or not to check phone numbers.
  90. */
  91. dialOutEnabled: boolean,
  92. /**
  93. * Array with the query types that will be executed -
  94. * "conferenceRooms" | "user" | "room".
  95. */
  96. peopleSearchQueryTypes: Array<string>,
  97. /**
  98. * The url to query for people.
  99. */
  100. peopleSearchUrl: string,
  101. /**
  102. * The jwt token to pass to the search service.
  103. */
  104. jwt: string
  105. };
  106. /**
  107. * Combines directory search with phone number validation to produce a single
  108. * set of invite search results.
  109. *
  110. * @param {string} query - Text to search.
  111. * @param {GetInviteResultsOptions} options - Options to use when searching.
  112. * @returns {Promise<*>}
  113. */
  114. export function getInviteResultsForQuery(
  115. query: string,
  116. options: GetInviteResultsOptions
  117. ): Promise<*> {
  118. const text = query.trim();
  119. const {
  120. dialOutAuthUrl,
  121. addPeopleEnabled,
  122. dialOutEnabled,
  123. peopleSearchQueryTypes,
  124. peopleSearchUrl,
  125. jwt
  126. } = options;
  127. let peopleSearchPromise;
  128. if (addPeopleEnabled && text) {
  129. peopleSearchPromise = searchDirectory(
  130. peopleSearchUrl,
  131. jwt,
  132. text,
  133. peopleSearchQueryTypes);
  134. } else {
  135. peopleSearchPromise = Promise.resolve([]);
  136. }
  137. let hasCountryCode = text.startsWith('+');
  138. let phoneNumberPromise;
  139. // Phone numbers are handled a specially to enable both cases of restricting
  140. // numbers to telephone number-y numbers and accepting any arbitrary string,
  141. // which may be valid for SIP (jigasi) calls. If the dialOutAuthUrl is
  142. // defined, then it is assumed the call is to a telephone number and
  143. // some validation of the number is completed, with the + sign used as a way
  144. // for the UI to detect and enforce the usage of a country code. If the
  145. // dialOutAuthUrl is not defined, accept anything because this is assumed
  146. // to be the SIP (jigasi) case.
  147. if (dialOutEnabled && dialOutAuthUrl && isMaybeAPhoneNumber(text)) {
  148. let numberToVerify = text;
  149. // When the number to verify does not start with a +, we assume no
  150. // proper country code has been entered. In such a case, prepend 1 for
  151. // the country code. The service currently takes care of prepending the
  152. // +.
  153. if (!hasCountryCode && !text.startsWith('1')) {
  154. numberToVerify = `1${numberToVerify}`;
  155. }
  156. // The validation service works properly when the query is digits only
  157. // so ensure only digits get sent.
  158. numberToVerify = getDigitsOnly(numberToVerify);
  159. phoneNumberPromise = checkDialNumber(numberToVerify, dialOutAuthUrl);
  160. } else if (dialOutEnabled && !dialOutAuthUrl) {
  161. // fake having a country code to hide the country code reminder
  162. hasCountryCode = true;
  163. // With no auth url, let's say the text is a valid number
  164. phoneNumberPromise = Promise.resolve({
  165. allow: true,
  166. country: '',
  167. phone: text
  168. });
  169. } else {
  170. phoneNumberPromise = Promise.resolve({});
  171. }
  172. return Promise.all([ peopleSearchPromise, phoneNumberPromise ])
  173. .then(([ peopleResults, phoneResults ]) => {
  174. const results = [
  175. ...peopleResults
  176. ];
  177. /**
  178. * This check for phone results is for the day the call to searching
  179. * people might return phone results as well. When that day comes
  180. * this check will make it so the server checks are honored and the
  181. * local appending of the number is not done. The local appending of
  182. * the phone number can then be cleaned up when convenient.
  183. */
  184. const hasPhoneResult
  185. = peopleResults.find(result => result.type === 'phone');
  186. if (!hasPhoneResult && typeof phoneResults.allow === 'boolean') {
  187. results.push({
  188. allowed: phoneResults.allow,
  189. country: phoneResults.country,
  190. type: 'phone',
  191. number: phoneResults.phone,
  192. originalEntry: text,
  193. showCountryCodeReminder: !hasCountryCode
  194. });
  195. }
  196. return results;
  197. });
  198. }
  199. /**
  200. * Creates a message describing how to dial in to the conference.
  201. *
  202. * @returns {string}
  203. */
  204. export function getInviteText({
  205. _conferenceName,
  206. _localParticipantName,
  207. _inviteUrl,
  208. _locationUrl,
  209. _dialIn,
  210. _liveStreamViewURL,
  211. phoneNumber,
  212. t
  213. }: Object) {
  214. const inviteURL = _decodeRoomURI(_inviteUrl);
  215. let invite = _localParticipantName
  216. ? t('info.inviteURLFirstPartPersonal', { name: _localParticipantName })
  217. : t('info.inviteURLFirstPartGeneral');
  218. invite += t('info.inviteURLSecondPart', {
  219. url: inviteURL
  220. });
  221. if (_liveStreamViewURL) {
  222. const liveStream = t('info.inviteLiveStream', {
  223. url: _liveStreamViewURL
  224. });
  225. invite = `${invite}\n${liveStream}`;
  226. }
  227. if (shouldDisplayDialIn(_dialIn)) {
  228. const dial = t('info.invitePhone', {
  229. number: phoneNumber,
  230. conferenceID: _dialIn.conferenceID
  231. });
  232. const moreNumbers = t('info.invitePhoneAlternatives', {
  233. url: getDialInfoPageURL(
  234. _conferenceName,
  235. _locationUrl
  236. ),
  237. silentUrl: `${inviteURL}#config.startSilent=true`
  238. });
  239. invite = `${invite}\n${dial}\n${moreNumbers}`;
  240. }
  241. return invite;
  242. }
  243. /**
  244. * Helper for determining how many of each type of user is being invited. Used
  245. * for logging and sending analytics related to invites.
  246. *
  247. * @param {Array} inviteItems - An array with the invite items, as created in
  248. * {@link _parseQueryResults}.
  249. * @returns {Object} An object with keys as user types and values as the number
  250. * of invites for that type.
  251. */
  252. export function getInviteTypeCounts(inviteItems: Array<Object> = []) {
  253. const inviteTypeCounts = {};
  254. inviteItems.forEach(({ type }) => {
  255. if (!inviteTypeCounts[type]) {
  256. inviteTypeCounts[type] = 0;
  257. }
  258. inviteTypeCounts[type]++;
  259. });
  260. return inviteTypeCounts;
  261. }
  262. /**
  263. * Sends a post request to an invite service.
  264. *
  265. * @param {string} inviteServiceUrl - The invite service that generates the
  266. * invitation.
  267. * @param {string} inviteUrl - The url to the conference.
  268. * @param {string} jwt - The jwt token to pass to the search service.
  269. * @param {Immutable.List} inviteItems - The list of the "user" or "room" type
  270. * items to invite.
  271. * @returns {Promise} - The promise created by the request.
  272. */
  273. export function invitePeopleAndChatRooms( // eslint-disable-line max-params
  274. inviteServiceUrl: string,
  275. inviteUrl: string,
  276. jwt: string,
  277. inviteItems: Array<Object>
  278. ): Promise<void> {
  279. if (!inviteItems || inviteItems.length === 0) {
  280. return Promise.resolve();
  281. }
  282. return fetch(
  283. `${inviteServiceUrl}?token=${jwt}`,
  284. {
  285. body: JSON.stringify({
  286. 'invited': inviteItems,
  287. 'url': inviteUrl
  288. }),
  289. method: 'POST',
  290. headers: {
  291. 'Content-Type': 'application/json'
  292. }
  293. }
  294. );
  295. }
  296. /**
  297. * Determines if adding people is currently enabled.
  298. *
  299. * @param {boolean} state - Current state.
  300. * @returns {boolean} Indication of whether adding people is currently enabled.
  301. */
  302. export function isAddPeopleEnabled(state: Object): boolean {
  303. const { peopleSearchUrl } = state['features/base/config'];
  304. return !isGuest(state) && Boolean(peopleSearchUrl);
  305. }
  306. /**
  307. * Determines if dial out is currently enabled or not.
  308. *
  309. * @param {boolean} state - Current state.
  310. * @returns {boolean} Indication of whether dial out is currently enabled.
  311. */
  312. export function isDialOutEnabled(state: Object): boolean {
  313. const { conference } = state['features/base/conference'];
  314. return isLocalParticipantModerator(state)
  315. && conference && conference.isSIPCallingSupported();
  316. }
  317. /**
  318. * Determines if the current user is guest or not.
  319. *
  320. * @param {Object} state - Current state.
  321. * @returns {boolean}
  322. */
  323. export function isGuest(state: Object): boolean {
  324. return state['features/base/jwt'].isGuest;
  325. }
  326. /**
  327. * Checks whether a string looks like it could be for a phone number.
  328. *
  329. * @param {string} text - The text to check whether or not it could be a phone
  330. * number.
  331. * @private
  332. * @returns {boolean} True if the string looks like it could be a phone number.
  333. */
  334. function isMaybeAPhoneNumber(text: string): boolean {
  335. if (!isPhoneNumberRegex().test(text)) {
  336. return false;
  337. }
  338. const digits = getDigitsOnly(text);
  339. return Boolean(digits.length);
  340. }
  341. /**
  342. * RegExp to use to determine if some text might be a phone number.
  343. *
  344. * @returns {RegExp}
  345. */
  346. function isPhoneNumberRegex(): RegExp {
  347. let regexString = '^[0-9+()-\\s]*$';
  348. if (typeof interfaceConfig !== 'undefined') {
  349. regexString = interfaceConfig.PHONE_NUMBER_REGEX || regexString;
  350. }
  351. return new RegExp(regexString);
  352. }
  353. /**
  354. * Sends an ajax request to a directory service.
  355. *
  356. * @param {string} serviceUrl - The service to query.
  357. * @param {string} jwt - The jwt token to pass to the search service.
  358. * @param {string} text - Text to search.
  359. * @param {Array<string>} queryTypes - Array with the query types that will be
  360. * executed - "conferenceRooms" | "user" | "room".
  361. * @returns {Promise} - The promise created by the request.
  362. */
  363. export function searchDirectory( // eslint-disable-line max-params
  364. serviceUrl: string,
  365. jwt: string,
  366. text: string,
  367. queryTypes: Array<string> = [ 'conferenceRooms', 'user', 'room' ]
  368. ): Promise<Array<Object>> {
  369. const query = encodeURIComponent(text);
  370. const queryTypesString = encodeURIComponent(JSON.stringify(queryTypes));
  371. return fetch(`${serviceUrl}?query=${query}&queryTypes=${
  372. queryTypesString}&jwt=${jwt}`)
  373. .then(response => {
  374. const jsonify = response.json();
  375. if (response.ok) {
  376. return jsonify;
  377. }
  378. return jsonify
  379. .then(result => Promise.reject(result));
  380. })
  381. .catch(error => {
  382. logger.error(
  383. 'Error searching directory:', error);
  384. return Promise.reject(error);
  385. });
  386. }
  387. /**
  388. * Returns descriptive text that can be used to invite participants to a meeting
  389. * (share via mobile or use it for calendar event description).
  390. *
  391. * @param {Object} state - The current state.
  392. * @param {string} inviteUrl - The conference/location URL.
  393. * @param {boolean} useHtml - Whether to return html text.
  394. * @returns {Promise<string>} A {@code Promise} resolving with a
  395. * descriptive text that can be used to invite participants to a meeting.
  396. */
  397. export function getShareInfoText(
  398. state: Object, inviteUrl: string, useHtml: ?boolean): Promise<string> {
  399. let roomUrl = _decodeRoomURI(inviteUrl);
  400. const includeDialInfo = state['features/base/config'] !== undefined;
  401. if (useHtml) {
  402. roomUrl = `<a href="${roomUrl}">${roomUrl}</a>`;
  403. }
  404. let infoText = i18next.t('share.mainText', { roomUrl });
  405. if (includeDialInfo) {
  406. const { room } = parseURIString(inviteUrl);
  407. let numbersPromise;
  408. if (state['features/invite'].numbers
  409. && state['features/invite'].conferenceID) {
  410. numbersPromise = Promise.resolve(state['features/invite']);
  411. } else {
  412. // we are requesting numbers and conferenceId directly
  413. // not using updateDialInNumbers, because custom room
  414. // is specified and we do not want to store the data
  415. // in the state
  416. const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
  417. = state['features/base/config'];
  418. const mucURL = hosts && hosts.muc;
  419. if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
  420. // URLs for fetching dial in numbers not defined
  421. return Promise.resolve(infoText);
  422. }
  423. numbersPromise = Promise.all([
  424. getDialInNumbers(dialInNumbersUrl, room, mucURL),
  425. getDialInConferenceID(dialInConfCodeUrl, room, mucURL)
  426. ]).then(([ numbers, {
  427. conference, id, message } ]) => {
  428. if (!conference || !id) {
  429. return Promise.reject(message);
  430. }
  431. return {
  432. numbers,
  433. conferenceID: id
  434. };
  435. });
  436. }
  437. return numbersPromise.then(
  438. ({ conferenceID, numbers }) => {
  439. const phoneNumber = _getDefaultPhoneNumber(numbers) || '';
  440. return `${
  441. i18next.t('info.dialInNumber')} ${
  442. phoneNumber} ${
  443. i18next.t('info.dialInConferenceID')} ${
  444. conferenceID}#\n\n`;
  445. })
  446. .catch(error =>
  447. logger.error('Error fetching numbers or conferenceID', error))
  448. .then(defaultDialInNumber => {
  449. let dialInfoPageUrl = getDialInfoPageURL(
  450. room,
  451. state['features/base/connection'].locationURL);
  452. if (useHtml) {
  453. dialInfoPageUrl
  454. = `<a href="${dialInfoPageUrl}">${dialInfoPageUrl}</a>`;
  455. }
  456. infoText += i18next.t('share.dialInfoText', {
  457. defaultDialInNumber,
  458. dialInfoPageUrl });
  459. return infoText;
  460. });
  461. }
  462. return Promise.resolve(infoText);
  463. }
  464. /**
  465. * Generates the URL for the static dial in info page.
  466. *
  467. * @param {string} conferenceName - The conference name.
  468. * @param {Object} locationURL - The current location URL, the object coming
  469. * from state ['features/base/connection'].locationURL.
  470. * @returns {string}
  471. */
  472. export function getDialInfoPageURL(
  473. conferenceName: string,
  474. locationURL: Object) {
  475. const origin = locationURL.origin;
  476. const pathParts = locationURL.pathname.split('/');
  477. pathParts.length = pathParts.length - 1;
  478. const newPath = pathParts.reduce((accumulator, currentValue) => {
  479. if (currentValue) {
  480. return `${accumulator}/${currentValue}`;
  481. }
  482. return accumulator;
  483. }, '');
  484. return `${origin}${newPath}/static/dialInInfo.html?room=${_decodeRoomURI(conferenceName)}`;
  485. }
  486. /**
  487. * Generates the URL for the static dial in info page.
  488. *
  489. * @param {string} uri - The conference URI string.
  490. * @returns {string}
  491. */
  492. export function getDialInfoPageURLForURIString(
  493. uri: ?string) {
  494. if (!uri) {
  495. return undefined;
  496. }
  497. const { protocol, host, contextRoot, room } = parseURIString(uri);
  498. return `${protocol}//${host}${contextRoot}static/dialInInfo.html?room=${room}`;
  499. }
  500. /**
  501. * Returns whether or not dial-in related UI should be displayed.
  502. *
  503. * @param {Object} dialIn - Dial in information.
  504. * @returns {boolean}
  505. */
  506. export function shouldDisplayDialIn(dialIn: Object) {
  507. const { conferenceID, numbers, numbersEnabled } = dialIn;
  508. const phoneNumber = _getDefaultPhoneNumber(numbers);
  509. return Boolean(
  510. conferenceID
  511. && numbers
  512. && numbersEnabled
  513. && phoneNumber);
  514. }
  515. /**
  516. * Sets the internal state of which dial-in number to display.
  517. *
  518. * @param {Array<string>|Object} dialInNumbers - The array or object of
  519. * numbers to choose a number from.
  520. * @private
  521. * @returns {string|null}
  522. */
  523. export function _getDefaultPhoneNumber(
  524. dialInNumbers: ?Object): ?string {
  525. if (!dialInNumbers) {
  526. return null;
  527. }
  528. if (Array.isArray(dialInNumbers)) {
  529. // new syntax follows
  530. // find the default country inside dialInNumbers, US one
  531. // or return the first one
  532. const defaultNumber = dialInNumbers.find(number => number.default);
  533. if (defaultNumber) {
  534. return defaultNumber.formattedNumber;
  535. }
  536. return dialInNumbers.length > 0
  537. ? dialInNumbers[0].formattedNumber : null;
  538. }
  539. const { numbers } = dialInNumbers;
  540. if (numbers && Object.keys(numbers).length > 0) {
  541. // deprecated and will be removed
  542. const firstRegion = Object.keys(numbers)[0];
  543. return firstRegion && numbers[firstRegion][0];
  544. }
  545. return null;
  546. }
  547. /**
  548. * Decodes URI only if doesn't contain a space(' ').
  549. *
  550. * @param {string} url - The string to decode.
  551. * @returns {string} - It the string contains space, encoded value is '%20' returns
  552. * same string, otherwise decoded one.
  553. * @private
  554. */
  555. export function _decodeRoomURI(url: string) {
  556. let roomUrl = url;
  557. // we want to decode urls when the do not contain space, ' ', which url encoded is %20
  558. if (roomUrl && !roomUrl.includes('%20')) {
  559. roomUrl = decodeURI(roomUrl);
  560. }
  561. // Handles a special case where the room name has % encoded, the decoded will have
  562. // % followed by a char (non-digit) which is not a valid URL and room name ... so we do not
  563. // want to show this decoded
  564. if (roomUrl.match(/.*%[^\d].*/)) {
  565. return url;
  566. }
  567. return roomUrl;
  568. }
  569. /**
  570. * Returns the stored conference id.
  571. *
  572. * @param {Object | Function} stateful - The Object or Function that can be
  573. * resolved to a Redux state object with the toState function.
  574. * @returns {string}
  575. */
  576. export function getConferenceId(stateful: Object | Function) {
  577. return toState(stateful)['features/invite'].conferenceID;
  578. }
  579. /**
  580. * Returns the default dial in number from the store.
  581. *
  582. * @param {Object | Function} stateful - The Object or Function that can be
  583. * resolved to a Redux state object with the toState function.
  584. * @returns {string | null}
  585. */
  586. export function getDefaultDialInNumber(stateful: Object | Function) {
  587. return _getDefaultPhoneNumber(toState(stateful)['features/invite'].numbers);
  588. }
  589. /**
  590. * Executes the dial out request.
  591. *
  592. * @param {string} url - The url for dialing out.
  593. * @param {Object} body - The body of the request.
  594. * @param {string} reqId - The unique request id.
  595. * @returns {Object}
  596. */
  597. export async function executeDialOutRequest(url: string, body: Object, reqId: string) {
  598. const res = await fetch(url, {
  599. method: 'POST',
  600. headers: {
  601. 'Content-Type': 'application/json',
  602. 'request-id': reqId
  603. },
  604. body: JSON.stringify(body)
  605. });
  606. const json = await res.json();
  607. return res.ok ? json : Promise.reject(json);
  608. }
  609. /**
  610. * Executes the dial out status request.
  611. *
  612. * @param {string} url - The url for dialing out.
  613. * @param {string} reqId - The unique request id used on the dial out request.
  614. * @returns {Object}
  615. */
  616. export async function executeDialOutStatusRequest(url: string, reqId: string) {
  617. const res = await fetch(url, {
  618. method: 'GET',
  619. headers: {
  620. 'Content-Type': 'application/json',
  621. 'request-id': reqId
  622. }
  623. });
  624. const json = await res.json();
  625. return res.ok ? json : Promise.reject(json);
  626. }