Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat: introduce ConferenceUrl module
paweldomasf7bfe8d8bf59
diff --git a/app.js b/app.jsindex 49b4b1059f..cdf8abb572 100644--- a/app.js+++ b/app.js@@ -19,6 +19,7 @@ import 'aui-experimental-css';window.toastr = require("toastr");import URLProcessor from "./modules/config/URLProcessor";+import ConferenceUrl from './modules/URL/ConferenceUrl';import RoomnameGenerator from './modules/util/RoomnameGenerator';import UI from "./modules/UI/UI";@@ -47,6 +48,18 @@ function pushHistoryState(roomName, URL) {return null;}+/**+ * Replaces current history state(replaces the URL displayed by the browser).+ * @param {string} newUrl the URL string which is to be displayed by the browser+ * to the user.+ */+function replaceHistoryState (newUrl) {+ if (window.history+ && typeof window.history.replaceState === 'function') {+ window.history.replaceState({}, document.title, newUrl);+ }+}+/*** Builds and returns the room name.*/@@ -107,6 +120,10 @@ function setTokenData() {function init() {setTokenData();+ // Initialize the conference URL handler+ ConferenceUrl.init(window.location);+ // Clean up the URL displayed by the browser+ replaceHistoryState(ConferenceUrl.getInviteUrl());var isUIReady = APP.UI.start();if (isUIReady) {APP.conference.init({roomName: buildRoomName()}).then(function () {diff --git a/modules/UI/UI.js b/modules/UI/UI.jsindex 144fef378d..94292d4470 100644--- a/modules/UI/UI.js+++ b/modules/UI/UI.js@@ -258,19 +258,6 @@ UI.setLocalRaisedHandStatus = (raisedHandStatus) => {*/UI.initConference = function () {let id = APP.conference.getMyUserId();-- // Do not include query parameters in the invite URL- // "https:" + "//" + "example.com:8888" + "/SomeConference1245"- var inviteURL = window.location.protocol + "//" +- window.location.host + window.location.pathname;-- this.emitEvent(UIEvents.INVITE_URL_INITIALISED, inviteURL);-- // Clean up the URL displayed by the browser- if (window.history && typeof window.history.replaceState === 'function') {- window.history.replaceState({}, document.title, inviteURL);- }-// Add myself to the contact list.UI.ContactList.addContact(id, true);diff --git a/modules/UI/invite/Invite.js b/modules/UI/invite/Invite.jsindex 0d5ecdf11b..24708fe2ee 100644--- a/modules/UI/invite/Invite.js+++ b/modules/UI/invite/Invite.js@@ -3,6 +3,7 @@import InviteDialogView from './InviteDialogView';import createRoomLocker from './RoomLocker';import UIEvents from '../../../service/UI/UIEvents';+import ConferenceUrl from '../../URL/ConferenceUrl';const ConferenceEvents = JitsiMeetJS.events.conference;@@ -14,6 +15,7 @@ const ConferenceEvents = JitsiMeetJS.events.conference;class Invite {constructor(conference) {this.conference = conference;+ this.inviteUrl = ConferenceUrl.getInviteUrl();this.createRoomLocker(conference);this.registerListeners();}@@ -48,11 +50,6 @@ class Invite {APP.UI.addListener( UIEvents.INVITE_CLICKED,() => { this.openLinkDialog(); });- APP.UI.addListener( UIEvents.INVITE_URL_INITIALISED,- (inviteUrl) => {- this.updateInviteUrl(inviteUrl);- });-APP.UI.addListener( UIEvents.PASSWORD_REQUIRED,() => {this.setLockedFromElsewhere(true);diff --git a/modules/UI/reload_overlay/PageReloadOverlay.js b/modules/UI/reload_overlay/PageReloadOverlay.jsindex 15436597bf..bb16216702 100644--- a/modules/UI/reload_overlay/PageReloadOverlay.js+++ b/modules/UI/reload_overlay/PageReloadOverlay.js@@ -1,6 +1,6 @@/* global $, APP, AJS */-import { reload } from '../../util/helpers';+import ConferenceUrl from '../../URL/ConferenceUrl';let $overlay;@@ -78,9 +78,8 @@ function start(timeoutSeconds) {updateDisplay();if (timeLeft === 0) {- console.info("Reloading!");window.clearInterval(intervalId);- reload();+ ConferenceUrl.reload();}}, 1000);}diff --git a/modules/URL/ConferenceUrl.js b/modules/URL/ConferenceUrl.jsnew file mode 100644index 0000000000..dab1abbef3--- /dev/null+++ b/modules/URL/ConferenceUrl.js@@ -0,0 +1,73 @@++import { redirect } from '../util/helpers';++/**+ * Stores the original conference room URL with all parameters.+ * @type {string}+ */+let originalURL;++/**+ * A simplified version of the conference URL stripped out of the parameters+ * which should be used for sending invites.+ * @type {string}+ */+let inviteURL;++/**+ * The modules stores information about the URL used to start the conference and+ * provides utility methods for dealing with conference URL and reloads.+ */+export default {+ /**+ * Initializes the module.+ *+ * @param location an object which stores provides the info about conference+ * URL(would be 'window.location' for the Web app). The params below are+ * described based on the following example URL:+ *+ * https://example.com:8888/SomeConference1245?opt=1#somehash+ *+ * @param location.href full URL with all parameters, would be the whole URL+ * from the example string above.+ *+ * @param location.host the host part of the URL, 'example.com' from+ * the sample URL above.+ *+ * @param location.pathname the path part of the URL, would be+ * '/SomeConference1245' from the example above.+ *+ * @param location.protocol the protocol part of the URL, would be 'https:'+ * from the sample URL.+ */+ init(location) {+ originalURL = location.href;+ // "https:" + "//" + "example.com:8888" + "/SomeConference1245"+ inviteURL+ = location.protocol + "//" + location.host + location.pathname;+ console.info("Stored original conference URL: " + originalURL);+ console.info("Conference URL for invites: " + inviteURL);+ },+ /**+ * Obtains the conference invite URL.+ * @return {string} the URL pointing o the conference which is mean to be+ * used to invite new participants.+ */+ getInviteUrl() {+ return inviteURL;+ },+ /**+ * Obtains full conference URL with all original parameters.+ * @return {string} the original URL used to open the current conference.+ */+ getOriginalUrl() {+ return originalURL;+ },+ /**+ * Reloads the conference using original URL with all of the parameters.+ */+ reload() {+ console.info("Reloading the conference using URL: " + originalURL);+ redirect(originalURL);+ }+};diff --git a/modules/util/helpers.js b/modules/util/helpers.jsindex 9d74d1ccce..6296b0973e 100644--- a/modules/util/helpers.js+++ b/modules/util/helpers.js@@ -20,6 +20,15 @@ export function reload () {window.location.reload();}+/**+ * Redirects to new URL.+ * @param {string} url the URL pointing to the location where the user should+ * be redirected to.+ */+export function redirect (url) {+ window.location.replace(url);+}+/*** Prints the error and reports it to the global error handler.* @param e {Error} the errordiff --git a/service/UI/UIEvents.js b/service/UI/UIEvents.jsindex ed2b492e5b..28ba055355 100644--- a/service/UI/UIEvents.js+++ b/service/UI/UIEvents.js@@ -145,11 +145,6 @@ export default {*/DISPLAY_NAME_CHANGED: "UI.display_name_changed",- /**- * Indicates that the invite url has been initialised.- */- INVITE_URL_INITIALISED: "UI.invite_url_initialised",-/*** Indicates that a password is required for the call.*/