Commit 6cab7fcc authored by JC Brand's avatar JC Brand

Fix failing tests due to refactoring

updates #161
parent b889637f
This diff is collapsed.
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
test_utils.openChatBoxFor(_converse, contact_jid); test_utils.openChatBoxFor(_converse, contact_jid);
var chatview = _converse.chatboxviews.get(contact_jid); var chatview = _converse.chatboxviews.get(contact_jid);
chatview.model.set('otr_status', UNVERIFIED); 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+'"]'); var $hints = $(stanza.nodeTree).find('[xmlns="'+Strophe.NS.HINTS+'"]');
expect($hints.length).toBe(3); expect($hints.length).toBe(3);
expect($hints.get(0).tagName).toBe('no-store'); expect($hints.get(0).tagName).toBe('no-store');
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
var chatbox = _converse.chatboxes.get(sender_jid); var chatbox = _converse.chatboxes.get(sender_jid);
spyOn(_converse.connection, 'send'); spyOn(_converse.connection, 'send');
chatbox.set('otr_status', 1); // Set OTR status to UNVERIFIED, to mock an encrypted session 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()); var $sent = $(_converse.connection.send.calls.argsFor(0)[0].tree());
expect($sent.find('body').siblings('private').length).toBe(1); expect($sent.find('body').siblings('private').length).toBe(1);
expect($sent.find('private').length).toBe(1); expect($sent.find('private').length).toBe(1);
......
...@@ -623,7 +623,6 @@ ...@@ -623,7 +623,6 @@
username = attrs.sender === 'me' && __('me') || fullname; username = attrs.sender === 'me' && __('me') || fullname;
template = attrs.is_spoiler ? tpl_spoiler_message : tpl_message; template = attrs.is_spoiler ? tpl_spoiler_message : tpl_message;
} }
text = u.geoUriToHttp(text, _converse); text = u.geoUriToHttp(text, _converse);
const msg_time = moment(attrs.time) || moment; const msg_time = moment(attrs.time) || moment;
......
...@@ -71,6 +71,18 @@ ...@@ -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) { shouldPlayNotification ($message) {
/* Don't play a notification if this is an OTR message but /* Don't play a notification if this is an OTR message but
* encryption is not yet set up. That would mean that the * encryption is not yet set up. That would mean that the
...@@ -271,18 +283,6 @@ ...@@ -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) { parseMessageForCommands (text) {
const { _converse } = this.__super__; const { _converse } = this.__super__;
const match = text.replace(/^\s*/, "").match(/^\/(.*)\s*$/); const match = text.replace(/^\s*/, "").match(/^\/(.*)\s*$/);
......
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