Updates #1003. Handle bare MUC room JIDs

This commit is contained in:
JC Brand 2018-01-29 14:51:49 +01:00
parent 6dfd2f8855
commit 852e9b5c85
3 changed files with 10 additions and 12 deletions

View File

@ -10,7 +10,7 @@
- #994 TypeError when using the `user.login` API.
- #995 `ChildNode.replaceWith` is not available in Internet Explorer or Safari. Use `Node.replaceChild` instead.
- #1000 Scroll to bottom when maximizing a chat room.
- #1003 Don't list MUC domain in rooms list.
- #1003 Handle bare MUC room JIDs
### Translation changes

View File

@ -319,8 +319,8 @@
function openRoom (jid) {
if (!u.isValidJID(jid)) {
return converse.log(
if (!u.isValidMUCJID(jid)) {
return _converse.log(
`Invalid JID "${jid}" provided in URL fragment`,
Strophe.LogLevel.WARN
);
@ -1187,9 +1187,8 @@
nick = this.model.get('nick');
}
const room = this.model.get('jid');
const node = Strophe.getNodeFromJid(room);
const domain = Strophe.getDomainFromJid(room);
return node + "@" + domain + (nick !== null ? `/${nick}` : "");
const jid = Strophe.getBareJidFromJid(room);
return jid + (nick !== null ? `/${nick}` : "");
},
registerHandlers () {
@ -2652,11 +2651,6 @@
},
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')
@ -2816,7 +2810,7 @@
}
return {
'jid': jid,
'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)) || jid
}
},

View File

@ -367,6 +367,10 @@
return _.filter(jid.split('@')).length === 2 && !jid.startsWith('@') && !jid.endsWith('@');
};
u.isValidMUCJID = function (jid) {
return !jid.startsWith('@') && !jid.endsWith('@');
};
u.isSameBareJID = function (jid1, jid2) {
return Strophe.getBareJidFromJid(jid1).toLowerCase() ===
Strophe.getBareJidFromJid(jid2).toLowerCase();