Don't play sound notifications for...
OTR messages which are setting up an encrypted session.
This commit is contained in:
parent
e27dfa060a
commit
e94904e4a1
@ -1,11 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
## 0.10.2 (Unreleased)
|
||||
## 0.11.0 (Unreleased)
|
||||
|
||||
- #261 show_controlbox_by_default config not working [diditopher]
|
||||
- #573 xgettext build error: `'javascript' unknown`
|
||||
- Split converse.js into different modules. The code for the OTR and MUC
|
||||
features are now in separate modules and these can be removed completely from
|
||||
the build. [jcbrand]
|
||||
- Don't play sound notifications for OTR messages which are setting up an
|
||||
encrypted session. [jcbrand]
|
||||
- Save scroll position on minimize and restore it on maximize [rlanvin]
|
||||
- #261 show_controlbox_by_default config not working [diditopher]
|
||||
- #566 Do not steal the focus when the chatbox opens automatically [rlanvin]
|
||||
- #573 xgettext build error: `'javascript' unknown` [jcbrand]
|
||||
|
||||
## 0.10.1 (2016-02-06)
|
||||
|
||||
|
@ -955,6 +955,28 @@
|
||||
});
|
||||
},
|
||||
|
||||
isOnlyChatStateNotification: function ($msg) {
|
||||
// See XEP-0085 Chat State Notification
|
||||
return (
|
||||
$msg.find('body').length === 0 && (
|
||||
$msg.find(ACTIVE).length !== 0 ||
|
||||
$msg.find(COMPOSING).length !== 0 ||
|
||||
$msg.find(INACTIVE).length !== 0 ||
|
||||
$msg.find(PAUSED).length !== 0 ||
|
||||
$msg.find(GONE).length !== 0
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
shouldPlayNotification: function ($message) {
|
||||
var $forwarded = $message.find('forwarded');
|
||||
if ($forwarded.length) {
|
||||
return false;
|
||||
}
|
||||
var is_me = Strophe.getBareJidFromJid($message.attr('from')) === converse.bare_jid;
|
||||
return !this.isOnlyChatStateNotification($message) && !is_me;
|
||||
},
|
||||
|
||||
createMessage: function ($message, $delay, archive_id) {
|
||||
$delay = $delay || $message.find('delay');
|
||||
var body = $message.children('body').text(),
|
||||
@ -2313,19 +2335,6 @@
|
||||
});
|
||||
},
|
||||
|
||||
isOnlyChatStateNotification: function ($msg) {
|
||||
// See XEP-0085 Chat State Notification
|
||||
return (
|
||||
$msg.find('body').length === 0 && (
|
||||
$msg.find(ACTIVE).length !== 0 ||
|
||||
$msg.find(COMPOSING).length !== 0 ||
|
||||
$msg.find(INACTIVE).length !== 0 ||
|
||||
$msg.find(PAUSED).length !== 0 ||
|
||||
$msg.find(GONE).length !== 0
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
onMessage: function (message) {
|
||||
/* Handler method for all incoming single-user chat "message" stanzas.
|
||||
*/
|
||||
@ -2374,7 +2383,7 @@
|
||||
if (msgid && chatbox.messages.findWhere({msgid: msgid})) {
|
||||
return true; // We already have this message stored.
|
||||
}
|
||||
if (!this.isOnlyChatStateNotification($message) && !is_me && !$forwarded.length) {
|
||||
if (chatbox.shouldPlayNotification($message)) {
|
||||
converse.playNotification();
|
||||
}
|
||||
chatbox.createMessage($message, $delay, archive_id);
|
||||
|
@ -109,10 +109,27 @@
|
||||
}
|
||||
},
|
||||
|
||||
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
|
||||
* OTR session is still being established, so there are no
|
||||
* "visible" OTR messages being exchanged.
|
||||
*/
|
||||
return this._super.shouldPlayNotification.apply(this, arguments) &&
|
||||
!(this.isOTRMessage($message) && !_.contains([UNVERIFIED, VERIFIED], this.get('otr_status')));
|
||||
},
|
||||
|
||||
createMessage: function ($message, $delay, archive_id) {
|
||||
var converse = this._super.converse;
|
||||
var $body = $message.children('body');
|
||||
var text = ($body.length > 0 ? $body.text() : undefined);
|
||||
var converse = this._super.converse,
|
||||
$body = $message.children('body'),
|
||||
text = ($body.length > 0 ? $body.text() : undefined);
|
||||
|
||||
if ((!text) || (!converse.allow_otr)) {
|
||||
return this._super.createMessage.apply(this, arguments);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user