Commit d1d81bf9 authored by JC Brand's avatar JC Brand

Bugfix. Remove condition before fetching members

parent bb0c0fcd
...@@ -145,10 +145,8 @@ ...@@ -145,10 +145,8 @@
chatroomview.close(); chatroomview.close();
_converse.muc_instant_rooms = false; _converse.muc_instant_rooms = false;
var sendIQ = _converse.connection.sendIQ; const sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
sent_IQ = iq;
sent_IQ_els.push(iq.nodeTree);
IQ_id = sendIQ.bind(this)(iq, callback, errback); IQ_id = sendIQ.bind(this)(iq, callback, errback);
}); });
// Test with configuration // Test with configuration
...@@ -199,15 +197,18 @@ ...@@ -199,15 +197,18 @@
.c('status', {code:'201'}); .c('status', {code:'201'});
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
expect(_converse.connection.sendIQ).toHaveBeenCalled(); expect(_converse.connection.sendIQ).toHaveBeenCalled();
expect(sent_IQ.toLocaleString()).toBe(
`<iq id="${IQ_id}" to="room@conference.example.org" type="get" xmlns="jabber:client">`+ const IQ_stanzas = _converse.connection.IQ_stanzas;
`<query xmlns="http://jabber.org/protocol/muc#owner"/></iq>` const iq = IQ_stanzas.filter(s => s.querySelector(`query[xmlns="${Strophe.NS.MUC_OWNER}"]`)).pop();
); expect(Strophe.serialize(iq)).toBe(
`<iq id="${iq.getAttribute('id')}" to="room@conference.example.org" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/muc#owner"/></iq>`);
const node = u.toStanza(` const node = u.toStanza(`
<iq xmlns="jabber:client" <iq xmlns="jabber:client"
type="result" type="result"
to="dummy@localhost/pda" to="dummy@localhost/pda"
from="room@conference.example.org" id="${IQ_id}"> from="room@conference.example.org" id="${iq.getAttribute('id')}">
<query xmlns="http://jabber.org/protocol/muc#owner"> <query xmlns="http://jabber.org/protocol/muc#owner">
<x xmlns="jabber:x:data" type="form"> <x xmlns="jabber:x:data" type="form">
<title>Configuration for room@conference.example.org</title> <title>Configuration for room@conference.example.org</title>
...@@ -244,10 +245,8 @@ ...@@ -244,10 +245,8 @@
spyOn(chatroomview.model, 'sendConfiguration').and.callThrough(); spyOn(chatroomview.model, 'sendConfiguration').and.callThrough();
_converse.connection._dataRecv(test_utils.createRequest(node)); _converse.connection._dataRecv(test_utils.createRequest(node));
await test_utils.waitUntil(() => chatroomview.model.sendConfiguration.calls.count() === 1); await test_utils.waitUntil(() => chatroomview.model.sendConfiguration.calls.count() === 1);
var sent_stanza = sent_IQ_els.pop();
while (sent_stanza.getAttribute('type') !== 'set') { const sent_stanza = IQ_stanzas.filter(s => s.getAttribute('type') === 'set').pop();
sent_stanza = sent_IQ_els.pop();
}
expect(sizzle('field[var="muc#roomconfig_roomname"] value', sent_stanza).pop().textContent).toBe('Room'); expect(sizzle('field[var="muc#roomconfig_roomname"] value', sent_stanza).pop().textContent).toBe('Room');
expect(sizzle('field[var="muc#roomconfig_roomdesc"] value', sent_stanza).pop().textContent).toBe('Welcome to this groupchat'); expect(sizzle('field[var="muc#roomconfig_roomdesc"] value', sent_stanza).pop().textContent).toBe('Welcome to this groupchat');
expect(sizzle('field[var="muc#roomconfig_persistentroom"] value', sent_stanza).pop().textContent).toBe('1'); expect(sizzle('field[var="muc#roomconfig_persistentroom"] value', sent_stanza).pop().textContent).toBe('1');
...@@ -372,17 +371,19 @@ ...@@ -372,17 +371,19 @@
.c('status').attrs({code:'201'}).nodeTree; .c('status').attrs({code:'201'}).nodeTree;
_converse.connection._dataRecv(test_utils.createRequest(presence)); _converse.connection._dataRecv(test_utils.createRequest(presence));
var info_text = view.el.querySelector('.chat-content .chat-info').textContent; const info_text = view.el.querySelector('.chat-content .chat-info').textContent;
expect(info_text).toBe('A new groupchat has been created'); expect(info_text).toBe('A new groupchat has been created');
// An instant room is created by saving the default configuratoin. // An instant room is created by saving the default configuratoin.
// //
/* <iq to="myroom@conference.chat.example.org" type="set" xmlns="jabber:client" id="5025e055-036c-4bc5-a227-706e7e352053:sendIQ"> /* <iq to="myroom@conference.chat.example.org" type="set" xmlns="jabber:client" id="5025e055-036c-4bc5-a227-706e7e352053:sendIQ">
* <query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query> * <query xmlns="http://jabber.org/protocol/muc#owner"><x xmlns="jabber:x:data" type="submit"/></query>
* </iq> * </iq>
*/ */
expect(sent_IQ.toLocaleString()).toBe( const iq = IQ_stanzas.filter(s => s.querySelector(`query[xmlns="${Strophe.NS.MUC_OWNER}"]`)).pop();
`<iq id="${IQ_id}" to="lounge@localhost" type="set" xmlns="jabber:client">`+ expect(Strophe.serialize(iq)).toBe(
`<iq id="${iq.getAttribute('id')}" to="lounge@localhost" type="set" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/muc#owner"><x type="submit" xmlns="jabber:x:data"/>`+ `<query xmlns="http://jabber.org/protocol/muc#owner"><x type="submit" xmlns="jabber:x:data"/>`+
`</query></iq>`); `</query></iq>`);
done(); done();
......
This diff is collapsed.
...@@ -221,13 +221,15 @@ converse.plugins.add('converse-muc', { ...@@ -221,13 +221,15 @@ converse.plugins.add('converse-muc', {
}, },
async onConnectionStatusChanged () { async onConnectionStatusChanged () {
if (this.get('connection_status') === converse.ROOMSTATUS.ENTERED && if (this.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
_converse.auto_register_muc_nickname &&
!this.get('reserved_nick') &&
await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'))) {
this.occupants.fetchMembers(); this.occupants.fetchMembers();
this.registerNickname()
if (_converse.auto_register_muc_nickname &&
!this.get('reserved_nick') &&
await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'))) {
this.registerNickname()
}
} }
}, },
...@@ -664,7 +666,7 @@ converse.plugins.add('converse-muc', { ...@@ -664,7 +666,7 @@ converse.plugins.add('converse-muc', {
* Given a <field> element, return a copy with a <value> child if * Given a <field> element, return a copy with a <value> child if
* we can find a value for it in this rooms config. * we can find a value for it in this rooms config.
* @private * @private
* @method _converse.ChatRoom#autoConfigureChatRoom * @method _converse.ChatRoom#addFieldValue
* @returns { Element } * @returns { Element }
*/ */
addFieldValue (field) { addFieldValue (field) {
......
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