Commit b4aeb942 authored by JC Brand's avatar JC Brand

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

parent 6bfcce5f
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
- Updated onDisconnected method to fire disconnected event even if `auto_reconnect = false`. [kamranzafar] - Updated onDisconnected method to fire disconnected event even if `auto_reconnect = false`. [kamranzafar]
- Bugfix: MAM messages weren't being fetched oldest first. [jcbrand] - Bugfix: MAM messages weren't being fetched oldest first. [jcbrand]
- Add processing hints to chat state notifications [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] - #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] - #650 Don't ignore incoming messages with same JID as current user (might be MAM archived) [jcbrand]
......
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
converse.shouldNotifyOfMessage = function (message) { converse.shouldNotifyOfMessage = function (message) {
/* Is this a message worthy of notification? /* Is this a message worthy of notification?
*/ */
if (utils.isOTRMessage(message)) {
return false;
}
var $message = $(message), var $message = $(message),
$forwarded = $message.find('forwarded'); $forwarded = $message.find('forwarded');
if ($forwarded.length) { if ($forwarded.length) {
......
...@@ -96,12 +96,6 @@ ...@@ -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) { shouldPlayNotification: function ($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
...@@ -109,7 +103,7 @@ ...@@ -109,7 +103,7 @@
* "visible" OTR messages being exchanged. * "visible" OTR messages being exchanged.
*/ */
return this._super.shouldPlayNotification.apply(this, arguments) && 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) { createMessage: function ($message, $delay, original_stanza) {
...@@ -296,7 +290,7 @@ ...@@ -296,7 +290,7 @@
createMessageStanza: function () { createMessageStanza: function () {
var stanza = this._super.createMessageStanza.apply(this, arguments); 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 // OTR messages aren't carbon copied
stanza.c('private', {'xmlns': Strophe.NS.CARBONS}).up() stanza.c('private', {'xmlns': Strophe.NS.CARBONS}).up()
.c('no-store', {'xmlns': Strophe.NS.HINTS}).up() .c('no-store', {'xmlns': Strophe.NS.HINTS}).up()
......
...@@ -149,6 +149,13 @@ ...@@ -149,6 +149,13 @@
return str; 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) { isHeadlineMessage: function (message) {
var $message = $(message), var $message = $(message),
from_jid = $message.attr('from'); from_jid = $message.attr('from');
......
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