diff --git a/JitsiConference.js b/JitsiConference.js index 0c6f0f8119..eb5b496209 100644 --- a/JitsiConference.js +++ b/JitsiConference.js @@ -4012,11 +4012,11 @@ JitsiConference.prototype.lobbyDenyAccess = function(id) { /** * Approves the request to join the conference to a participant waiting in the lobby. * - * @param {string} id The participant id. + * @param {string|Array} param The participant id or an array of ids. */ -JitsiConference.prototype.lobbyApproveAccess = function(id) { +JitsiConference.prototype.lobbyApproveAccess = function(param) { if (this.room) { - this.room.getLobby().approveAccess(id); + this.room.getLobby().approveAccess(param); } }; diff --git a/modules/xmpp/Lobby.js b/modules/xmpp/Lobby.js index a8d2426448..6db86c7a1d 100644 --- a/modules/xmpp/Lobby.js +++ b/modules/xmpp/Lobby.js @@ -410,9 +410,9 @@ export default class Lobby { /** * Should be possible only for moderators. - * @param id + * @param param or an array of ids. */ - approveAccess(id) { + approveAccess(param) { if (!this.isSupported() || !this.mainRoom.isModerator()) { return; } @@ -425,23 +425,38 @@ export default class Lobby { mainRoomJid = this.mainRoom.getBreakoutRooms().getMainRoomJid(); } - const memberRoomJid = Object.keys(this.lobbyRoom.members) - .find(j => Strophe.getResourceFromJid(j) === id); + const membersToApprove = []; + let ids = param; + + if (!Array.isArray(param)) { + ids = [ param ]; + } + + ids.forEach(id => { + const memberRoomJid = Object.keys(this.lobbyRoom.members) + .find(j => Strophe.getResourceFromJid(j) === id); - if (memberRoomJid) { - const jid = this.lobbyRoom.members[memberRoomJid].jid; + if (memberRoomJid) { + membersToApprove.push(this.lobbyRoom.members[memberRoomJid].jid); + } else { + logger.error(`Not found member for ${memberRoomJid} in lobby room.`); + } + }); + + if (membersToApprove.length > 0) { const msgToSend = $msg({ to: mainRoomJid }) - .c('x', { xmlns: 'http://jabber.org/protocol/muc#user' }) - .c('invite', { to: jid }); + .c('x', { xmlns: 'http://jabber.org/protocol/muc#user' }); + + membersToApprove.forEach(jid => { + msgToSend.c('invite', { to: jid }).up(); + }); this.xmpp.connection.sendIQ(msgToSend, () => { }, // eslint-disable-line no-empty-function e => { - logger.error(`Error sending invite for ${jid}`, e); + logger.error(`Error sending invite for ${membersToApprove}`, e); }); - } else { - logger.error(`Not found member for ${memberRoomJid} in lobby room.`); } } }