parent
b889637f8d
commit
6cab7fcc41
@ -416,7 +416,7 @@
|
||||
expect(view).toBeDefined();
|
||||
var $toolbar = $(view.el).find('ul.chat-toolbar');
|
||||
expect($toolbar.length).toBe(1);
|
||||
expect($toolbar.children('li').length).toBe(3);
|
||||
expect($toolbar.children('li').length).toBe(2);
|
||||
done();
|
||||
}));
|
||||
|
||||
@ -754,7 +754,7 @@
|
||||
'time': moment().format(),
|
||||
'message': msg_text
|
||||
});
|
||||
view.sendMessage(message);
|
||||
view.model.sendMessage(message);
|
||||
var $chat_content = $(view.el).find('.chat-content');
|
||||
var msg_txt = $chat_content.find('.chat-message:last').find('.chat-msg-content').text();
|
||||
expect(msg_txt).toEqual(msg_text);
|
||||
@ -770,7 +770,7 @@
|
||||
'time': moment().format(),
|
||||
'message': msg_text
|
||||
});
|
||||
view.sendMessage(message);
|
||||
view.model.sendMessage(message);
|
||||
msg_txt = $chat_content.find('.chat-message:last').find('.chat-msg-content').text();
|
||||
expect(msg_txt).toEqual(msg_text);
|
||||
|
||||
@ -1455,9 +1455,9 @@
|
||||
expect(_converse.emit).toHaveBeenCalledWith('chatBoxFocused', jasmine.any(Object));
|
||||
var view = _converse.chatboxviews.get(contact_jid);
|
||||
var message = 'This message is sent from this chatbox';
|
||||
spyOn(view, 'sendMessage').and.callThrough();
|
||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||
test_utils.sendMessage(view, message);
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.messages.length, 2);
|
||||
expect(_converse.emit.calls.mostRecent().args, ['messageSend', message]);
|
||||
expect($(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content').text()).toEqual(message);
|
||||
@ -1476,9 +1476,9 @@
|
||||
test_utils.openChatBoxFor(_converse, contact_jid);
|
||||
var view = _converse.chatboxviews.get(contact_jid);
|
||||
var message = '<p>This message contains <em>some</em> <b>markup</b></p>';
|
||||
spyOn(view, 'sendMessage').and.callThrough();
|
||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||
test_utils.sendMessage(view, message);
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
var msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.text()).toEqual(message);
|
||||
expect(msg.html()).toEqual('<p>This message contains <em>some</em> <b>markup</b></p>');
|
||||
@ -1497,9 +1497,9 @@
|
||||
test_utils.openChatBoxFor(_converse, contact_jid);
|
||||
var view = _converse.chatboxviews.get(contact_jid);
|
||||
var message = 'This message contains a hyperlink: www.opkode.com';
|
||||
spyOn(view, 'sendMessage').and.callThrough();
|
||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||
test_utils.sendMessage(view, message);
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
var msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.text()).toEqual(message);
|
||||
expect(msg.html()).toEqual('This message contains a hyperlink: <a target="_blank" rel="noopener" href="http://www.opkode.com">www.opkode.com</a>');
|
||||
@ -1518,10 +1518,10 @@
|
||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||
test_utils.openChatBoxFor(_converse, contact_jid);
|
||||
var view = _converse.chatboxviews.get(contact_jid);
|
||||
spyOn(view, 'sendMessage').and.callThrough();
|
||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||
message = "http://www.opkode.com/'onmouseover='alert(1)'whatever";
|
||||
test_utils.sendMessage(view, message);
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.text()).toEqual(message);
|
||||
expect(msg.html()).toEqual('<a target="_blank" rel="noopener" href="http://www.opkode.com/%27onmouseover=%27alert%281%29%27whatever">http://www.opkode.com/\'onmouseover=\'alert(1)\'whatever</a>');
|
||||
@ -1529,7 +1529,7 @@
|
||||
message = 'http://www.opkode.com/"onmouseover="alert(1)"whatever';
|
||||
test_utils.sendMessage(view, message);
|
||||
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.text()).toEqual(message);
|
||||
expect(msg.html()).toEqual('<a target="_blank" rel="noopener" href="http://www.opkode.com/%22onmouseover=%22alert%281%29%22whatever">http://www.opkode.com/"onmouseover="alert(1)"whatever</a>');
|
||||
@ -1537,7 +1537,7 @@
|
||||
message = "https://en.wikipedia.org/wiki/Ender's_Game";
|
||||
test_utils.sendMessage(view, message);
|
||||
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.text()).toEqual(message);
|
||||
expect(msg.html()).toEqual('<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Ender%27s_Game">https://en.wikipedia.org/wiki/Ender\'s_Game</a>');
|
||||
@ -1545,7 +1545,7 @@
|
||||
message = "https://en.wikipedia.org/wiki/Ender%27s_Game";
|
||||
test_utils.sendMessage(view, message);
|
||||
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.text()).toEqual(message);
|
||||
expect(msg.html()).toEqual('<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Ender%27s_Game">https://en.wikipedia.org/wiki/Ender%27s_Game</a>');
|
||||
@ -1564,13 +1564,13 @@
|
||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||
test_utils.openChatBoxFor(_converse, contact_jid);
|
||||
var view = _converse.chatboxviews.get(contact_jid);
|
||||
spyOn(view, 'sendMessage').and.callThrough();
|
||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||
test_utils.sendMessage(view, message);
|
||||
|
||||
test_utils.waitUntil(function () {
|
||||
return $(view.el).find('.chat-content').find('.chat-message img').length;
|
||||
}, 1000).then(function () {
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
var msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.html()).toEqual(
|
||||
'<a target="_blank" rel="noopener" href="'+base_url+'/logo/conversejs-filled.svg"><img class="chat-image"'+
|
||||
@ -1581,7 +1581,7 @@
|
||||
return $(view.el).find('.chat-content').find('.chat-message img').length === 2;
|
||||
}, 1000);
|
||||
}).then(function () {
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
var msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.html()).toEqual(
|
||||
'<a target="_blank" rel="noopener" href="'+base_url+'/logo/conversejs-filled.svg?param1=val1&param2=val2"><img'+
|
||||
@ -1594,7 +1594,7 @@
|
||||
return $(view.el).find('.chat-content').find('.chat-message img').length === 4;
|
||||
}, 1000);
|
||||
}).then(function () {
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
var msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.html()).toEqual(
|
||||
'<a target="_blank" rel="noopener" href="'+base_url+'/logo/conversejs-filled.svg?param1=val1&param2=val2">'+
|
||||
@ -2722,13 +2722,13 @@
|
||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||
test_utils.openChatBoxFor(_converse, contact_jid);
|
||||
var view = _converse.chatboxviews.get(contact_jid);
|
||||
spyOn(view, 'sendMessage').and.callThrough();
|
||||
spyOn(view.model, 'sendMessage').and.callThrough();
|
||||
test_utils.sendMessage(view, message);
|
||||
|
||||
test_utils.waitUntil(function () {
|
||||
return $(view.el).find('.chat-content').find('.chat-message').length;
|
||||
}, 1000).then(function () {
|
||||
expect(view.sendMessage).toHaveBeenCalled();
|
||||
expect(view.model.sendMessage).toHaveBeenCalled();
|
||||
var msg = $(view.el).find('.chat-content').find('.chat-message').last().find('.chat-msg-content');
|
||||
expect(msg.html()).toEqual(
|
||||
'<a target="_blank" rel="noopener" href="https://www.openstreetmap.org/?mlat=37.786971&'+
|
||||
|
@ -85,7 +85,7 @@
|
||||
test_utils.openChatBoxFor(_converse, contact_jid);
|
||||
var chatview = _converse.chatboxviews.get(contact_jid);
|
||||
chatview.model.set('otr_status', UNVERIFIED);
|
||||
var stanza = chatview.createMessageStanza(new _converse.Message({ message: 'hello world'}));
|
||||
var stanza = chatview.model.createMessageStanza(new _converse.Message({ message: 'hello world'}));
|
||||
var $hints = $(stanza.nodeTree).find('[xmlns="'+Strophe.NS.HINTS+'"]');
|
||||
expect($hints.length).toBe(3);
|
||||
expect($hints.get(0).tagName).toBe('no-store');
|
||||
@ -111,7 +111,7 @@
|
||||
var chatbox = _converse.chatboxes.get(sender_jid);
|
||||
spyOn(_converse.connection, 'send');
|
||||
chatbox.set('otr_status', 1); // Set OTR status to UNVERIFIED, to mock an encrypted session
|
||||
chatbox.trigger('sendMessage', new _converse.Message({ message: msgtext }));
|
||||
chatbox.sendMessage(new _converse.Message({'message': msgtext}));
|
||||
var $sent = $(_converse.connection.send.calls.argsFor(0)[0].tree());
|
||||
expect($sent.find('body').siblings('private').length).toBe(1);
|
||||
expect($sent.find('private').length).toBe(1);
|
||||
|
@ -623,7 +623,6 @@
|
||||
username = attrs.sender === 'me' && __('me') || fullname;
|
||||
template = attrs.is_spoiler ? tpl_spoiler_message : tpl_message;
|
||||
}
|
||||
|
||||
text = u.geoUriToHttp(text, _converse);
|
||||
|
||||
const msg_time = moment(attrs.time) || moment;
|
||||
|
@ -71,6 +71,18 @@
|
||||
}
|
||||
},
|
||||
|
||||
createMessageStanza () {
|
||||
const stanza = this.__super__.createMessageStanza.apply(this, arguments);
|
||||
if (this.get('otr_status') !== UNENCRYPTED || utils.isOTRMessage(stanza.nodeTree)) {
|
||||
// OTR messages aren't carbon copied
|
||||
stanza.c('private', {'xmlns': Strophe.NS.CARBONS}).up()
|
||||
.c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
|
||||
.c('no-permanent-store', {'xmlns': Strophe.NS.HINTS}).up()
|
||||
.c('no-copy', {'xmlns': Strophe.NS.HINTS});
|
||||
}
|
||||
return stanza;
|
||||
},
|
||||
|
||||
shouldPlayNotification ($message) {
|
||||
/* Don't play a notification if this is an OTR message but
|
||||
* encryption is not yet set up. That would mean that the
|
||||
@ -271,18 +283,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
createMessageStanza () {
|
||||
const stanza = this.__super__.createMessageStanza.apply(this, arguments);
|
||||
if (this.model.get('otr_status') !== UNENCRYPTED || utils.isOTRMessage(stanza.nodeTree)) {
|
||||
// OTR messages aren't carbon copied
|
||||
stanza.c('private', {'xmlns': Strophe.NS.CARBONS}).up()
|
||||
.c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
|
||||
.c('no-permanent-store', {'xmlns': Strophe.NS.HINTS}).up()
|
||||
.c('no-copy', {'xmlns': Strophe.NS.HINTS});
|
||||
}
|
||||
return stanza;
|
||||
},
|
||||
|
||||
parseMessageForCommands (text) {
|
||||
const { _converse } = this.__super__;
|
||||
const match = text.replace(/^\s*/, "").match(/^\/(.*)\s*$/);
|
||||
|
Loading…
Reference in New Issue
Block a user