From ce048ef01fadfdcae5813923af03052f3836a09b Mon Sep 17 00:00:00 2001 From: Roman Melnyk Date: Fri, 23 Feb 2024 17:58:56 +0200 Subject: [PATCH 1/2] feat(JitsiConference): Separate thrown errors: "no conference name passed" and "it contains invalid characters like capital letters". --- JitsiConference.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/JitsiConference.js b/JitsiConference.js index 11bf18793e..fa35d3b50a 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -131,21 +131,26 @@ function _getCodecMimeType(codec) { * and so on... */ export default function JitsiConference(options) { - if (!options.name || options.name.toLowerCase() !== options.name.toString()) { - const errmsg - = 'Invalid conference name (no conference name passed or it ' - + 'contains invalid characters like capital letters)!'; - const additionalLogMsg = options.name - ? `roomName=${options.name}; condition - ${options.name.toLowerCase()}!==${options.name.toString()}` - : 'No room name passed!'; - - logger.error(`${errmsg} ${additionalLogMsg}`); + const name = options.name; + + // Conference name validation + if (!name) { + const errmsg = 'Invalid conference name (no conference name passed)!'; + + logger.error(`${errmsg} No room name passed!`); + throw new Error(errmsg); + } + if (name.toLowerCase() !== name.toString()) { + const errmsg = 'Invalid conference name (it contains invalid characters like capital letters)!'; + + logger.error(`${errmsg} roomName=${name}; condition - ${name.toLowerCase()}!==${name.toString()}`); throw new Error(errmsg); } + this.connection = options.connection; this.xmpp = this.connection?.xmpp; - if (this.xmpp.isRoomCreated(options.name, options.customDomain)) { + if (this.xmpp.isRoomCreated(name, options.customDomain)) { const errmsg = 'A conference with the same name has already been created!'; delete this.connection; @@ -476,7 +481,7 @@ JitsiConference.prototype._init = function(options = {}) { userName: config.statisticsDisplayName ? config.statisticsDisplayName : this.myUserId(), confID: config.confID || `${this.connection.options.hosts.domain}/${this.options.name}`, siteID: config.siteID, - roomName: this.options.name, + name: this.options.name, applicationName: config.applicationName }); Statistics.analytics.addPermanentProperties({ From 95b5874ee5665ff80ffaef6f4b259f696adebfbd Mon Sep 17 00:00:00 2001 From: Romick2005 <17779660+Romick2005@users.noreply.github.com> Date: Fri, 23 Feb 2024 23:28:44 +0200 Subject: [PATCH 2/2] Update JitsiConference.js Rollback invalid rename, --- JitsiConference.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JitsiConference.js b/JitsiConference.js index fa35d3b50a..4e7b9577c3 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -481,7 +481,7 @@ JitsiConference.prototype._init = function(options = {}) { userName: config.statisticsDisplayName ? config.statisticsDisplayName : this.myUserId(), confID: config.confID || `${this.connection.options.hosts.domain}/${this.options.name}`, siteID: config.siteID, - name: this.options.name, + roomName: this.options.name, applicationName: config.applicationName }); Statistics.analytics.addPermanentProperties({