From 95f7e7b70c59ce84240729bada0cce13bd088136 Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 8 Feb 2024 10:00:49 -0600 Subject: [PATCH] feat(lobby): Admin set function for multiple items. --- modules/xmpp/ChatRoom.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index 4ebd383801..43c1ebe078 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -1442,22 +1442,21 @@ export default class ChatRoom extends Listenable { setMembersOnly(enabled, onSuccess, onError) { if (enabled && Object.values(this.members).filter(m => !m.isFocus).length) { // first grant membership to all that are in the room - // currently there is a bug in prosody where it handles only the first item - // that's why we will send iq per member + const affiliationsIq = $iq({ + to: this.roomjid, + type: 'set' }) + .c('query', { + xmlns: 'http://jabber.org/protocol/muc#admin' }); + Object.values(this.members).forEach(m => { if (m.jid && !MEMBERS_AFFILIATIONS.includes(m.affiliation)) { - this.xmpp.connection.sendIQ( - $iq({ - to: this.roomjid, - type: 'set' }) - .c('query', { - xmlns: 'http://jabber.org/protocol/muc#admin' }) - .c('item', { - 'affiliation': 'member', - 'jid': Strophe.getBareJidFromJid(m.jid) - }).up().up()); + affiliationsIq.c('item', { + 'affiliation': 'member', + 'jid': Strophe.getBareJidFromJid(m.jid) + }).up(); } }); + this.xmpp.connection.sendIQ(affiliationsIq.up()); } const errorCallback = onError ? onError : () => {}; // eslint-disable-line no-empty-function