Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(external_api) drop legacy constructor arguments #15390

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 10 additions & 82 deletions modules/API/external/external_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,80 +194,6 @@ function changeParticipantNumber(APIInstance, number) {
APIInstance._numberOfParticipants += number;
}

/**
* Generates the URL for the iframe.
*
* @param {string} domain - The domain name of the server that hosts the
* conference.
* @param {string} [options] - Another optional parameters.
* @param {Object} [options.configOverwrite] - Object containing configuration
* options defined in config.js to be overridden.
* @param {Object} [options.interfaceConfigOverwrite] - Object containing
* configuration options defined in interface_config.js to be overridden.
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
* authentication.
* @param {string} [options.lang] - The meeting's default language.
* @param {string} [options.roomName] - The name of the room to join.
* @returns {string} The URL.
*/
function generateURL(domain, options = {}) {
return urlObjectToString({
...options,
url: `https://${domain}/#jitsi_meet_external_api_id=${id}`
});
}

/**
* Parses the arguments passed to the constructor. If the old format is used
* the function translates the arguments to the new format.
*
* @param {Array} args - The arguments to be parsed.
* @returns {Object} JS object with properties.
*/
function parseArguments(args) {
if (!args.length) {
return {};
}

const firstArg = args[0];

switch (typeof firstArg) {
case 'string': // old arguments format
case 'undefined': {
// Not sure which format but we are trying to parse the old
// format because if the new format is used everything will be undefined
// anyway.
const [
roomName,
width,
height,
parentNode,
configOverwrite,
interfaceConfigOverwrite,
jwt,
onload,
lang
] = args;

return {
roomName,
width,
height,
parentNode,
configOverwrite,
interfaceConfigOverwrite,
jwt,
onload,
lang
};
}
case 'object': // new arguments format
return args[0];
default:
throw new Error('Can\'t parse the arguments!');
}
}

/**
* Compute valid values for height and width. If a number is specified it's
* treated as pixel units. If the value is expressed in px, em, pt or
Expand Down Expand Up @@ -336,7 +262,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* @param {string} [options.release] - The key used for specifying release if enabled on the backend.
* @param {string} [options.sandbox] - Sandbox directive for the created iframe, if desired.
*/
constructor(domain, ...args) {
constructor(domain, options = {}) {
super();
const {
roomName = '',
Expand All @@ -345,21 +271,22 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
parentNode = document.body,
configOverwrite = {},
interfaceConfigOverwrite = {},
jwt = undefined,
lang = undefined,
onload = undefined,
jwt,
lang,
onload,
invitees,
iceServers,
devices,
userInfo,
e2eeKey,
release,
sandbox = ''
} = parseArguments(args);
sandbox
} = options;
const localStorageContent = jitsiLocalStorage.getItem('jitsiLocalStorage');

this._parentNode = parentNode;
this._url = generateURL(domain, {

this._url = urlObjectToString({
configOverwrite,
iceServers,
interfaceConfigOverwrite,
Expand All @@ -371,7 +298,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
appData: {
localStorageContent
},
release
release,
url: `https://${domain}/#jitsi_meet_external_api_id=${id}`
});

this._createIFrame(height, width, sandbox);
Expand Down
Loading