From 444e2b90df7013691f7548bcb2770ffff6f2f737 Mon Sep 17 00:00:00 2001 From: Gabriel Imre Date: Thu, 28 May 2020 13:39:48 +0300 Subject: [PATCH] callstats: add siteID passing; sanitize confID path --- conference.js | 15 ++++++++++++--- react/features/base/conference/actions.js | 6 +++++- react/features/base/jwt/middleware.js | 1 + react/features/base/util/uri.js | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/conference.js b/conference.js index 95ec73918..d8968c02a 100644 --- a/conference.js +++ b/conference.js @@ -101,7 +101,10 @@ import { trackAdded, trackRemoved } from './react/features/base/tracks'; -import { getJitsiMeetGlobalNS } from './react/features/base/util'; +import { + getBackendSafePath, + getJitsiMeetGlobalNS +} from './react/features/base/util'; import { showDesktopPicker } from './react/features/desktop-picker'; import { appendSuffix } from './react/features/display-name'; import { setE2EEKey } from './react/features/e2ee'; @@ -1364,7 +1367,13 @@ export default { const options = config; const { email, name: nick } = getLocalParticipant(APP.store.getState()); - const { locationURL } = APP.store.getState()['features/base/connection']; + const state = APP.store.getState(); + const { locationURL } = state['features/base/connection']; + const { tenant } = state['features/base/jwt']; + + if (tenant) { + options.siteID = tenant; + } if (options.enableDisplayNameInStats && nick) { options.statisticsDisplayName = nick; @@ -1376,7 +1385,7 @@ export default { options.applicationName = interfaceConfig.APP_NAME; options.getWiFiStatsMethod = this._getWiFiStatsMethod; - options.confID = `${locationURL.host}${locationURL.pathname}`; + options.confID = `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`; options.createVADProcessor = createRnnoiseProcessorPromise; // Disable CallStats, if requessted. diff --git a/react/features/base/conference/actions.js b/react/features/base/conference/actions.js index 61d3e8ac7..ffdb23fc5 100644 --- a/react/features/base/conference/actions.js +++ b/react/features/base/conference/actions.js @@ -24,6 +24,7 @@ import { } from '../participants'; import { getLocalTracks, trackAdded, trackRemoved } from '../tracks'; import { + getBackendSafePath, getBackendSafeRoomName, getJitsiMeetGlobalNS } from '../util'; @@ -417,7 +418,9 @@ export function createConference() { } const config = state['features/base/config']; + const { tenant } = state['features/base/jwt']; const { email, name: nick } = getLocalParticipant(state); + const conference = connection.initJitsiConference( @@ -425,7 +428,8 @@ export function createConference() { ...config, applicationName: getName(), getWiFiStatsMethod: getJitsiMeetGlobalNS().getWiFiStats, - confID: `${locationURL.host}${locationURL.pathname}`, + confID: `${locationURL.host}${getBackendSafePath(locationURL.pathname)}`, + siteID: tenant, statisticsDisplayName: config.enableDisplayNameInStats ? nick : undefined, statisticsId: config.enableEmailInStats ? email : undefined }); diff --git a/react/features/base/jwt/middleware.js b/react/features/base/jwt/middleware.js index 3b8285b0b..bcfb0c63f 100644 --- a/react/features/base/jwt/middleware.js +++ b/react/features/base/jwt/middleware.js @@ -146,6 +146,7 @@ function _setJWT(store, next, action) { action.callee = context.callee; action.group = context.group; action.server = context.server; + action.tenant = context.tenant; action.user = user; user && _overwriteLocalParticipant( diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.js index 142afe80f..4ecaa8589 100644 --- a/react/features/base/util/uri.js +++ b/react/features/base/util/uri.js @@ -99,6 +99,24 @@ function _fixURIStringScheme(uri: string) { return uri; } +/** + * Converts a path to a backend-safe format, by splitting the path '/' processing each part. + * Properly lowercased and url encoded. + * + * @param {string?} path - The path to convert. + * @returns {string?} + */ +export function getBackendSafePath(path: ?string): ?string { + if (!path) { + return path; + } + + return path + .split('/') + .map(getBackendSafeRoomName) + .join('/'); +} + /** * Converts a room name to a backend-safe format. Properly lowercased and url encoded. *