Commit d2a44c4c authored by JC Brand's avatar JC Brand

Fixes #1003 Don't list MUC domain in rooms list.

parent 3d32f695
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- #993 `moment.format` is not a function error when sending a message. - #993 `moment.format` is not a function error when sending a message.
- #994 TypeError when using the `user.login` API. - #994 TypeError when using the `user.login` API.
- #995 `ChildNode.replaceWith` is not available in Internet Explorer or Safari. Use `Node.replaceChild` instead. - #995 `ChildNode.replaceWith` is not available in Internet Explorer or Safari. Use `Node.replaceChild` instead.
- #1003 Don't list MUC domain in rooms list.
## 3.3.1 (2018-01-18) ## 3.3.1 (2018-01-18)
......
...@@ -1241,6 +1241,7 @@ ...@@ -1241,6 +1241,7 @@
// so we don't send out a presence stanza again. // so we don't send out a presence stanza again.
return this; return this;
} }
const stanza = $pres({ const stanza = $pres({
'from': _converse.connection.jid, 'from': _converse.connection.jid,
'to': this.getRoomJIDAndNick(nick) 'to': this.getRoomJIDAndNick(nick)
...@@ -2649,6 +2650,26 @@ ...@@ -2649,6 +2650,26 @@
this.removeSpinner(); this.removeSpinner();
}, },
roomStanzaItemToHTMLElement (room) {
if (!u.isValidJID(room.getAttribute('jid'), '@')) {
// Some XMPP servers return the MUC service in
// the list of rooms (see #1003).
return null;
}
const name = Strophe.unescapeNode(
room.getAttribute('name') ||
room.getAttribute('jid')
);
const div = document.createElement('div');
div.innerHTML = tpl_room_item({
'name': name,
'jid': room.getAttribute('jid'),
'open_title': __('Click to open this room'),
'info_title': __('Show more information on this room')
});
return div.firstChild;
},
onRoomsFound (iq) { onRoomsFound (iq) {
/* Handle the IQ stanza returned from the server, containing /* Handle the IQ stanza returned from the server, containing
* all its public rooms. * all its public rooms.
...@@ -2661,21 +2682,9 @@ ...@@ -2661,21 +2682,9 @@
available_chatrooms.innerHTML = tpl_rooms_results({ available_chatrooms.innerHTML = tpl_rooms_results({
'feedback_text': __('Rooms found') 'feedback_text': __('Rooms found')
}); });
const div = document.createElement('div');
const fragment = document.createDocumentFragment(); const fragment = document.createDocumentFragment();
for (let i=0; i<this.rooms.length; i++) { const children = _.reject(_.map(this.rooms, this.roomStanzaItemToHTMLElement), _.isNil)
const name = Strophe.unescapeNode( _.each(children, (child) => fragment.appendChild(child));
this.rooms[i].getAttribute('name') ||
this.rooms[i].getAttribute('jid')
);
div.innerHTML = tpl_room_item({
'name': name,
'jid': this.rooms[i].getAttribute('jid'),
'open_title': __('Click to open this room'),
'info_title': __('Show more information on this room')
});
fragment.appendChild(div.firstChild);
}
available_chatrooms.appendChild(fragment); available_chatrooms.appendChild(fragment);
const input_el = this.el.querySelector('input#show-rooms'); const input_el = this.el.querySelector('input#show-rooms');
input_el.classList.remove('hidden') input_el.classList.remove('hidden')
......
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