Commit 852e9b5c authored by JC Brand's avatar JC Brand

Updates #1003. Handle bare MUC room JIDs

parent 6dfd2f88
......@@ -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
......
......@@ -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
}
},
......
......@@ -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();
......
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