From 5671c5d6ca43015befde01d7bad20e42f83a8666 Mon Sep 17 00:00:00 2001 From: damencho Date: Fri, 20 Sep 2024 13:38:11 -0500 Subject: [PATCH] feat(moderator): Skips redirect events when moving to main from breakout. --- JitsiConference.js | 7 +++++++ modules/xmpp/ChatRoom.js | 3 +++ modules/xmpp/moderator.js | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/JitsiConference.js b/JitsiConference.js index 46ac2ad1da..ce09095cc5 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -674,6 +674,13 @@ JitsiConference.prototype.leave = async function(reason) { return; } + // let's check is this breakout + if (reason === 'switch_room' && this.getBreakoutRooms()?.isBreakoutRoom()) { + const mJid = this.getBreakoutRooms().getMainRoomJid(); + + this.xmpp.connection._breakoutMovingToMain = mJid; + } + const room = this.room; // Unregister connection state listeners diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index 7cf8ba4b0f..7142495f87 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -239,6 +239,9 @@ export default class ChatRoom extends Listenable { const preJoin = this.options.disableFocus ? Promise.resolve() + .finally(() => { + this.xmpp.connection._breakoutMovingToMain = undefined; + }) : this.xmpp.moderator.sendConferenceRequest(this.roomjid); preJoin.then(() => { diff --git a/modules/xmpp/moderator.js b/modules/xmpp/moderator.js index 64310cee27..6da7f92acf 100644 --- a/modules/xmpp/moderator.js +++ b/modules/xmpp/moderator.js @@ -357,6 +357,9 @@ export default class Moderator extends Listenable { } }).then(() => { this.conferenceRequestSent = true; + }) + .finally(() => { + this.xmpp.connection._breakoutMovingToMain = undefined; }); } @@ -411,7 +414,16 @@ export default class Moderator extends Listenable { this.getNextTimeout(true); // we want to ignore redirects when this is jibri (record/live-stream or a sip jibri) + // we ignore redirects when moving from a breakout room to the main room if (conferenceRequest.vnode && !this.options.iAmRecorder && !this.options.iAmSipGateway) { + if (this.connection._breakoutMovingToMain === roomJid) { + logger.info('Skipping redirect as we are moving from breakout to main.'); + + callback(); + + return; + } + logger.warn(`Redirected to: ${conferenceRequest.vnode} with focusJid ${conferenceRequest.focusJid}`); this.xmpp.eventEmitter.emit(CONNECTION_REDIRECTED, conferenceRequest.vnode, conferenceRequest.focusJid);