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