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 @@
_.partial(u.renderImageURL, _converse))(url);
}
const encrypted = this.model.get('encrypted');
let text = encrypted ? this.model.get('plaintext') : this.model.get('message');
let text = this.getMessageText();
const msg_content = msg.querySelector('.chat-msg__text');
if (text && text !== url) {
if (is_me_message) {
text = text.replace(/^\/me/, '');
}
const msg_content = msg.querySelector('.chat-msg__text');
if (text !== url) {
text = xss.filterXSS(text, {'whiteList': {}});
msg_content.innerHTML = _.flow(
_.partial(u.geoUriToHttp, _, _converse.geouri_replacement),
......@@ -217,8 +216,16 @@
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 () {
const text = this.model.get('message');
const text = this.getMessageText();
if (!text) {
return false;
}
......
......@@ -10,7 +10,7 @@
define(["converse-core"], factory);
}(this, function (converse) {
"use strict";
const { Strophe, _ } = converse.env,
const { Strophe, _, sizzle } = converse.env,
u = converse.env.utils;
converse.plugins.add('converse-notification', {
......@@ -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, {
body: message.querySelector('body').textContent,
body: body,
lang: _converse.locale,
icon: _converse.notification_icon
});
......
......@@ -409,6 +409,7 @@
if (this.get('omemo_active') && attrs.message) {
attrs['is_encrypted'] = true;
attrs['plaintext'] = attrs.message;
const message = this.messages.create(attrs);
this.getBundlesAndBuildSessions()
.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