You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. declare var $: Function;
  2. /**
  3. * Sends an ajax request to a directory service.
  4. *
  5. * @param {string} serviceUrl - The service to query.
  6. * @param {string} jwt - The jwt token to pass to the search service.
  7. * @param {string} text - Text to search.
  8. * @param {Array<string>} queryTypes - Array with the query types that will be
  9. * executed - "conferenceRooms" | "user" | "room".
  10. * @returns {Promise} - The promise created by the request.
  11. */
  12. export function searchPeople( // eslint-disable-line max-params
  13. serviceUrl,
  14. jwt,
  15. text,
  16. queryTypes = [ 'conferenceRooms', 'user', 'room' ]) {
  17. const queryTypesString = JSON.stringify(queryTypes);
  18. return new Promise((resolve, reject) => {
  19. $.getJSON(`${serviceUrl}?query=${encodeURIComponent(text)}`
  20. + `&queryTypes=${queryTypesString}&jwt=${jwt}`,
  21. response => resolve(response)
  22. ).fail((jqxhr, textStatus, error) =>
  23. reject(error)
  24. );
  25. });
  26. }
  27. /**
  28. * Sends a post request to an invite service.
  29. *
  30. * @param {string} inviteServiceUrl - The invite service that generates the
  31. * invitation.
  32. * @param {string} inviteUrl - The url to the conference.
  33. * @param {string} jwt - The jwt token to pass to the search service.
  34. * @param {Immutable.List} people - The list of the "user" type items to invite.
  35. * @returns {Promise} - The promise created by the request.
  36. */
  37. export function invitePeople(inviteServiceUrl, inviteUrl, jwt, people) { // eslint-disable-line max-params, max-len
  38. return new Promise((resolve, reject) => {
  39. $.post(`${inviteServiceUrl}?token=${jwt}`,
  40. JSON.stringify({
  41. 'invited': people,
  42. 'url': inviteUrl }),
  43. response => resolve(response),
  44. 'json')
  45. .fail((jqxhr, textStatus, error) =>
  46. reject(error)
  47. );
  48. });
  49. }
  50. /**
  51. * Invites room participants to the conference through the SIP Jibri service.
  52. *
  53. * @param {JitsiMeetConference} conference - The conference to which the rooms
  54. * will be invited to.
  55. * @param {Immutable.List} rooms - The list of the "videosipgw" type items to
  56. * invite.
  57. * @returns {void}
  58. */
  59. export function inviteRooms(conference, rooms) {
  60. for (const room of rooms) {
  61. const sipAddress = room.id;
  62. const displayName = room.name;
  63. if (sipAddress && displayName) {
  64. const newSession
  65. = conference.createVideoSIPGWSession(sipAddress, displayName);
  66. newSession.start();
  67. } else {
  68. console.error(
  69. `No display name or sip number for ${JSON.stringify(room)}`);
  70. }
  71. }
  72. }