Commit 060fd945 authored by JC Brand's avatar JC Brand

Allow features to be passed in to `openAndEnterChatRoom`

parent 2d511a5e
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
return _converse.api.rooms.open(`${room}@${server}`); return _converse.api.rooms.open(`${room}@${server}`);
}; };
utils.openAndEnterChatRoom = async function (_converse, room, server, nick) { utils.openAndEnterChatRoom = async function (_converse, room, server, nick, features=[]) {
const room_jid = `${room}@${server}`.toLowerCase(); const room_jid = `${room}@${server}`.toLowerCase();
const stanzas = _converse.connection.IQ_stanzas; const stanzas = _converse.connection.IQ_stanzas;
await _converse.api.rooms.open(room_jid); await _converse.api.rooms.open(room_jid);
...@@ -137,22 +137,25 @@ ...@@ -137,22 +137,25 @@
'category': 'conference', 'category': 'conference',
'name': room[0].toUpperCase() + room.slice(1), 'name': room[0].toUpperCase() + room.slice(1),
'type': 'text' 'type': 'text'
}).up() }).up();
.c('feature', {'var': 'http://jabber.org/protocol/muc'}).up() features = features || [
.c('feature', {'var': 'jabber:iq:register'}).up() 'http://jabber.org/protocol/muc',
.c('feature', {'var': 'muc_passwordprotected'}).up() 'jabber:iq:register',
.c('feature', {'var': 'muc_hidden'}).up() 'muc_passwordprotected',
.c('feature', {'var': 'muc_temporary'}).up() 'muc_hidden',
.c('feature', {'var': 'muc_open'}).up() 'muc_temporary',
.c('feature', {'var': 'muc_unmoderated'}).up() 'muc_open',
.c('feature', {'var': 'muc_nonanonymous'}) 'muc_unmoderated',
.c('x', { 'xmlns':'jabber:x:data', 'type':'result'}) 'muc_nonanonymous']
features.forEach(f => features_stanza.c('feature', {'var': f}).up());
features_stanza.c('x', { 'xmlns':'jabber:x:data', 'type':'result'})
.c('field', {'var':'FORM_TYPE', 'type':'hidden'}) .c('field', {'var':'FORM_TYPE', 'type':'hidden'})
.c('value').t('http://jabber.org/protocol/muc#roominfo').up().up() .c('value').t('http://jabber.org/protocol/muc#roominfo').up().up()
.c('field', {'type':'text-single', 'var':'muc#roominfo_description', 'label':'Description'}) .c('field', {'type':'text-single', 'var':'muc#roominfo_description', 'label':'Description'})
.c('value').t('This is the description').up().up() .c('value').t('This is the description').up().up()
.c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of occupants'}) .c('field', {'type':'text-single', 'var':'muc#roominfo_occupants', 'label':'Number of occupants'})
.c('value').t(0); .c('value').t(0);
_converse.connection._dataRecv(utils.createRequest(features_stanza)); _converse.connection._dataRecv(utils.createRequest(features_stanza));
const iq = await utils.waitUntil(() => _.filter( const iq = await utils.waitUntil(() => _.filter(
stanzas, stanzas,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment