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

This commit is contained in:
JC Brand 2018-09-07 15:23:16 +02:00
parent 06352b67c1
commit cfcab80147
3 changed files with 22 additions and 9 deletions

View File

@ -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');
if (is_me_message) {
text = text.replace(/^\/me/, '');
}
let text = this.getMessageText();
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': {}});
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;
}

View File

@ -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
});

View File

@ -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))