Don't use sound/desktop notification for OTR messages.

This commit is contained in:
JC Brand 2016-05-30 18:19:10 +00:00
parent 6bfcce5fcb
commit b4aeb94279
4 changed files with 13 additions and 8 deletions

View File

@ -10,6 +10,7 @@
- Updated onDisconnected method to fire disconnected event even if `auto_reconnect = false`. [kamranzafar]
- Bugfix: MAM messages weren't being fetched oldest first. [jcbrand]
- Add processing hints to chat state notifications [jcbrand]
- Don't use sound and desktop notifications for OTR messages (when setting up the session) [jcbrand]
- #553 Add processing hints to OTR messages [jcbrand]
- #650 Don't ignore incoming messages with same JID as current user (might be MAM archived) [jcbrand]

View File

@ -71,6 +71,9 @@
converse.shouldNotifyOfMessage = function (message) {
/* Is this a message worthy of notification?
*/
if (utils.isOTRMessage(message)) {
return false;
}
var $message = $(message),
$forwarded = $message.find('forwarded');
if ($forwarded.length) {

View File

@ -96,12 +96,6 @@
}
},
isOTRMessage: function ($message) {
var $body = $message.children('body'),
text = ($body.length > 0 ? $body.text() : undefined);
return !!text.match(/^\?OTR/);
},
shouldPlayNotification: function ($message) {
/* Don't play a notification if this is an OTR message but
* encryption is not yet set up. That would mean that the
@ -109,7 +103,7 @@
* "visible" OTR messages being exchanged.
*/
return this._super.shouldPlayNotification.apply(this, arguments) &&
!(this.isOTRMessage($message) && !_.contains([UNVERIFIED, VERIFIED], this.get('otr_status')));
!(utils.isOTRMessage($message[0]) && !_.contains([UNVERIFIED, VERIFIED], this.get('otr_status')));
},
createMessage: function ($message, $delay, original_stanza) {
@ -296,7 +290,7 @@
createMessageStanza: function () {
var stanza = this._super.createMessageStanza.apply(this, arguments);
if (this.model.get('otr_status') !== UNENCRYPTED) {
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()

View File

@ -149,6 +149,13 @@
return str;
},
isOTRMessage: function (message) {
var $body = $(message).children('body'),
text = ($body.length > 0 ? $body.text() : undefined);
return text && !!text.match(/^\?OTR/);
},
isHeadlineMessage: function (message) {
var $message = $(message),
from_jid = $message.attr('from');