Commit cfcab801 authored by JC Brand's avatar JC Brand

Don't inform of unencryptable OMEMO messages unless in debug mode

parent 06352b67
...@@ -131,13 +131,12 @@ ...@@ -131,13 +131,12 @@
_.partial(u.renderImageURL, _converse))(url); _.partial(u.renderImageURL, _converse))(url);
} }
const encrypted = this.model.get('encrypted'); let text = this.getMessageText();
let text = encrypted ? this.model.get('plaintext') : this.model.get('message');
if (is_me_message) {
text = text.replace(/^\/me/, '');
}
const msg_content = msg.querySelector('.chat-msg__text'); const msg_content = msg.querySelector('.chat-msg__text');
if (text !== url) { if (text && text !== url) {
if (is_me_message) {
text = text.replace(/^\/me/, '');
}
text = xss.filterXSS(text, {'whiteList': {}}); text = xss.filterXSS(text, {'whiteList': {}});
msg_content.innerHTML = _.flow( msg_content.innerHTML = _.flow(
_.partial(u.geoUriToHttp, _, _converse.geouri_replacement), _.partial(u.geoUriToHttp, _, _converse.geouri_replacement),
...@@ -217,8 +216,16 @@ ...@@ -217,8 +216,16 @@
this.model.message_versions_modal.show(ev); this.model.message_versions_modal.show(ev);
}, },
getMessageText () {
if (this.model.get('is_encrypted')) {
return this.model.get('plaintext') ||
(_converse.debug ? __('Unencryptable OMEMO message') : null);
}
return this.model.get('message');
},
isMeCommand () { isMeCommand () {
const text = this.model.get('message'); const text = this.getMessageText();
if (!text) { if (!text) {
return false; return false;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
define(["converse-core"], factory); define(["converse-core"], factory);
}(this, function (converse) { }(this, function (converse) {
"use strict"; "use strict";
const { Strophe, _ } = converse.env, const { Strophe, _, sizzle } = converse.env,
u = converse.env.utils; u = converse.env.utils;
converse.plugins.add('converse-notification', { converse.plugins.add('converse-notification', {
...@@ -165,8 +165,13 @@ ...@@ -165,8 +165,13 @@
} }
} }
} }
// TODO: we should suppress notifications if we cannot decrypt
// the message...
const body = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, message).length ?
__('OMEMO Message received') :
message.querySelector('body').textContent;
const n = new Notification(title, { const n = new Notification(title, {
body: message.querySelector('body').textContent, body: body,
lang: _converse.locale, lang: _converse.locale,
icon: _converse.notification_icon icon: _converse.notification_icon
}); });
......
...@@ -409,6 +409,7 @@ ...@@ -409,6 +409,7 @@
if (this.get('omemo_active') && attrs.message) { if (this.get('omemo_active') && attrs.message) {
attrs['is_encrypted'] = true; attrs['is_encrypted'] = true;
attrs['plaintext'] = attrs.message;
const message = this.messages.create(attrs); const message = this.messages.create(attrs);
this.getBundlesAndBuildSessions() this.getBundlesAndBuildSessions()
.then(devices => this.createOMEMOMessageStanza(message, devices)) .then(devices => this.createOMEMOMessageStanza(message, devices))
......
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