don't notify if only message delivery receipt
This commit is contained in:
Christoph Scholz 2019-09-24 11:49:39 +02:00 committed by JC Brand
parent e29849fe5e
commit bce8dc9113
3 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,7 @@
- #1712: `TypeError: plugin._features is not a function`
- Bugfix: process stanzas from mam one-by-one in order to correctly process message
receipts
- #1714 Bugfix: Don't notify the user in case we're receiving a message delivery receipt only
## 5.0.3 (2019-09-13)

View File

@ -87,6 +87,7 @@ converse.plugins.add('converse-notification', {
}
const is_me = Strophe.getBareJidFromJid(message.getAttribute('from')) === _converse.bare_jid;
return !u.isOnlyChatStateNotification(message) &&
!u.isOnlyMessageDeliveryReceipt(message) &&
!is_me &&
(_converse.show_desktop_notifications === 'all' || _converse.isMessageToHiddenChat(message));
};

View File

@ -148,6 +148,18 @@ u.isOnlyChatStateNotification = function (msg) {
return msg['chat_state'] && u.isEmptyMessage(msg);
};
u.isOnlyMessageDeliveryReceipt = function (msg) {
if (msg instanceof Element) {
// See XEP-0184 Message Delivery Receipts
return (msg.querySelector('body') === null) &&
(msg.querySelector('received') !== null);
}
if (msg instanceof Backbone.Model) {
msg = msg.attributes;
}
return msg['received'] && u.isEmptyMessage(msg);
};
u.isHeadlineMessage = function (_converse, message) {
const from_jid = message.getAttribute('from');
if (message.getAttribute('type') === 'headline') {