Skip to content

Commit

Permalink
feat(lobby): Adds an option to approve multiple participants.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Mar 1, 2024
1 parent 9ec93dc commit 87f9dcf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
6 changes: 3 additions & 3 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>} 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);
}
};

Expand Down
37 changes: 26 additions & 11 deletions modules/xmpp/Lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.`);
}
}
}

0 comments on commit 87f9dcf

Please sign in to comment.