mirror of https://github.com/jitsi/jitsi-meet
fix: When adding a room param to urls check for previous params. (#11607)
* fix: When adding a room param to urls check for previous params. * squash: Uses URL object to modify the url. * squash: Use common connection options from base/connection. Normalizes bosh url and for web. * squash: Adds release param to external api and handles it. * feat: Adds release handling for mobile(links in welcome page). * squash: Fixes comments.pull/11691/head jitsi-meet_7437
parent
7dd85bb6ad
commit
f3c6b54ffa
@ -0,0 +1,71 @@ |
||||
import _ from 'lodash'; |
||||
|
||||
import { |
||||
appendURLParam, |
||||
getBackendSafeRoomName, |
||||
parseURIString |
||||
} from '../util'; |
||||
|
||||
import logger from './logger'; |
||||
|
||||
/** |
||||
* Constructs options to be passed to the constructor of {@code JitsiConnection} |
||||
* based on the redux state. |
||||
* |
||||
* @param {Object} state - The redux state. |
||||
* @returns {Object} The options to be passed to the constructor of |
||||
* {@code JitsiConnection}. |
||||
*/ |
||||
export function constructOptions(state) { |
||||
// Deep clone the options to make sure we don't modify the object in the
|
||||
// redux store.
|
||||
const options = _.cloneDeep(state['features/base/config']); |
||||
|
||||
let { bosh, websocket } = options; |
||||
|
||||
// TESTING: Only enable WebSocket for some percentage of users.
|
||||
if (websocket && navigator.product === 'ReactNative') { |
||||
if ((Math.random() * 100) >= (options?.testing?.mobileXmppWsThreshold ?? 0)) { |
||||
websocket = undefined; |
||||
} |
||||
} |
||||
|
||||
// Normalize the BOSH URL.
|
||||
if (bosh && !websocket) { |
||||
const { locationURL } = state['features/base/connection']; |
||||
|
||||
if (bosh.startsWith('//')) { |
||||
// By default our config.js doesn't include the protocol.
|
||||
bosh = `${locationURL.protocol}${bosh}`; |
||||
} else if (bosh.startsWith('/')) { |
||||
// Handle relative URLs, which won't work on mobile.
|
||||
const { |
||||
protocol, |
||||
host, |
||||
contextRoot |
||||
} = parseURIString(locationURL.href); |
||||
|
||||
bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`; |
||||
} |
||||
} |
||||
|
||||
// WebSocket is preferred over BOSH.
|
||||
const serviceUrl = websocket || bosh; |
||||
|
||||
logger.log(`Using service URL ${serviceUrl}`); |
||||
|
||||
// Append room to the URL's search.
|
||||
const { room } = state['features/base/conference']; |
||||
|
||||
if (serviceUrl && room) { |
||||
const roomName = getBackendSafeRoomName(room); |
||||
|
||||
options.serviceUrl = appendURLParam(serviceUrl, 'room', roomName); |
||||
|
||||
if (options.websocketKeepAliveUrl) { |
||||
options.websocketKeepAliveUrl = appendURLParam(options.websocketKeepAliveUrl, 'room', roomName); |
||||
} |
||||
} |
||||
|
||||
return options; |
||||
} |
Loading…
Reference in new issue