Skip to content

Commit

Permalink
callstats: add siteID passing; sanitize confID path
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Imre authored and damencho committed May 28, 2020
1 parent 7de8899 commit 444e2b9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
15 changes: 12 additions & 3 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion react/features/base/conference/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from '../participants';
import { getLocalTracks, trackAdded, trackRemoved } from '../tracks';
import {
getBackendSafePath,
getBackendSafeRoomName,
getJitsiMeetGlobalNS
} from '../util';
Expand Down Expand Up @@ -417,15 +418,18 @@ 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(

getBackendSafeRoomName(room), {
...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
});
Expand Down
1 change: 1 addition & 0 deletions react/features/base/jwt/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 18 additions & 0 deletions react/features/base/util/uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 444e2b9

Please sign in to comment.