Skip to content

Commit

Permalink
feat(lobby): Admin set function for multiple items.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Feb 13, 2024
1 parent cc9b0e6 commit 95f7e7b
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions modules/xmpp/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 95f7e7b

Please sign in to comment.