Commit f779b9a3 authored by JC Brand's avatar JC Brand

Fixes #535. Room doesn't get opened when mixed-case JID is used.

parent 6dcafb5b
......@@ -2491,7 +2491,7 @@
name = $name.val().trim();
$name.val(''); // Clear the input
if (name && server) {
jid = Strophe.escapeNode(name.toLowerCase()) + '@' + server;
jid = Strophe.escapeNode(name.toLowerCase()) + '@' + server.toLowerCase();
$name.removeClass('error');
$server.removeClass('error');
this.model.save({muc_domain: server});
......@@ -3749,6 +3749,7 @@
* (String) jid - The JID of the user whose chat box we want
* (Boolean) create - Should a new chat box be created if none exists?
*/
jid = jid.toLowerCase();
var bare_jid = Strophe.getBareJidFromJid(jid);
var chatbox = this.get(bare_jid);
if (!chatbox && create) {
......@@ -6375,7 +6376,7 @@
'focus': view.focus.bind(view),
'get': chatbox.get.bind(chatbox),
'initiateOTR': chatbox.initiateOTR.bind(chatbox),
'is_chatroom': chatbox.is_chatroom,
'is_chatroom': view.is_chatroom,
'maximize': chatbox.maximize.bind(chatbox),
'minimize': chatbox.minimize.bind(chatbox),
'open': view.show.bind(view),
......@@ -6581,6 +6582,7 @@
throw new TypeError('rooms.open: invalid nick, must be string');
}
var _transform = function (jid) {
jid = jid.toLowerCase();
var chatroom = converse.chatboxes.get(jid);
converse.log('jid');
if (!chatroom) {
......
......@@ -6,6 +6,7 @@
down on chat event notifications. [jcbrand]
- #524 Added `auto_join_on_invite` parameter for automatically joining chatrooms. [ben]
- #521 Not sending presence when connecting after disconnection. [jcbrand]
- #535 Messages not received when room with mixed-case JID is used. [jcbrand]
- #536 Presence not sent out (in cases where it should) after page refresh. [jcbrand]
- #540 `bind is not a function` error for plugins without `initialize` method. [jcbrand]
- A chatroom invite might come from someone not in your roster list. [ben]
......
......@@ -317,6 +317,89 @@
}, converse));
}, converse));
describe("The \"rooms\" API", function () {
beforeEach(function () {
test_utils.closeAllChatBoxes();
test_utils.clearBrowserStorage();
converse.rosterview.model.reset();
test_utils.createContacts('current');
});
it("has a method 'get' which returns a wrapped chat room (if it exists)", function () {
test_utils.openChatRoom('lounge', 'localhost', 'dummy');
var jid = 'lounge@localhost';
var room = converse_api.rooms.get(jid);
expect(room instanceof Object).toBeTruthy();
expect(room.is_chatroom).toBeTruthy();
var chatroomview = converse.chatboxviews.get(jid);
expect(chatroomview.$el.is(':visible')).toBeTruthy();
chatroomview.close();
// Test with mixed case
test_utils.openChatRoom('Leisure', 'localhost', 'dummy');
jid = 'Leisure@localhost';
room = converse_api.rooms.get(jid);
expect(room instanceof Object).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
expect(chatroomview.$el.is(':visible')).toBeTruthy();
jid = 'leisure@localhost';
room = converse_api.rooms.get(jid);
expect(room instanceof Object).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
expect(chatroomview.$el.is(':visible')).toBeTruthy();
jid = 'leiSure@localhost';
room = converse_api.rooms.get(jid);
expect(room instanceof Object).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
expect(chatroomview.$el.is(':visible')).toBeTruthy();
chatroomview.close();
// Non-existing room
jid = 'lounge2@localhost';
room = converse_api.rooms.get(jid);
expect(typeof room === 'undefined').toBeTruthy();
});
it("has a method 'open' which opens and returns a wrapped chat box", function () {
// Test on chat room that doesn't exist.
var jid = 'lounge@localhost';
var room = converse_api.rooms.open(jid);
expect(room instanceof Object).toBeTruthy();
expect(room.is_chatroom).toBeTruthy();
var chatroomview = converse.chatboxviews.get(jid);
expect(chatroomview.$el.is(':visible')).toBeTruthy();
// Test again, now that the room exists.
room = converse_api.rooms.open(jid);
expect(room instanceof Object).toBeTruthy();
expect(room.is_chatroom).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid);
expect(chatroomview.$el.is(':visible')).toBeTruthy();
// Test with mixed case in JID
jid = 'Leisure@localhost';
room = converse_api.rooms.open(jid);
expect(room instanceof Object).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
expect(chatroomview.$el.is(':visible')).toBeTruthy();
jid = 'leisure@localhost';
room = converse_api.rooms.open(jid);
expect(room instanceof Object).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
expect(chatroomview.$el.is(':visible')).toBeTruthy();
jid = 'leiSure@localhost';
room = converse_api.rooms.open(jid);
expect(room instanceof Object).toBeTruthy();
chatroomview = converse.chatboxviews.get(jid.toLowerCase());
expect(chatroomview.$el.is(':visible')).toBeTruthy();
chatroomview.close();
});
});
describe("The \"settings\" API", $.proxy(function() {
beforeEach($.proxy(function () {
test_utils.closeAllChatBoxes();
......
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