Skip to content

Commit bce8dc9

Browse files
ChaosKid42jcbrand
authored andcommitted
Fixes #1714
don't notify if only message delivery receipt
1 parent e29849f commit bce8dc9

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- #1712: `TypeError: plugin._features is not a function`
88
- Bugfix: process stanzas from mam one-by-one in order to correctly process message
99
receipts
10+
- #1714 Bugfix: Don't notify the user in case we're receiving a message delivery receipt only
1011

1112
## 5.0.3 (2019-09-13)
1213

src/converse-notification.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ converse.plugins.add('converse-notification', {
8787
}
8888
const is_me = Strophe.getBareJidFromJid(message.getAttribute('from')) === _converse.bare_jid;
8989
return !u.isOnlyChatStateNotification(message) &&
90+
!u.isOnlyMessageDeliveryReceipt(message) &&
9091
!is_me &&
9192
(_converse.show_desktop_notifications === 'all' || _converse.isMessageToHiddenChat(message));
9293
};

src/headless/utils/core.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ u.isOnlyChatStateNotification = function (msg) {
148148
return msg['chat_state'] && u.isEmptyMessage(msg);
149149
};
150150

151+
u.isOnlyMessageDeliveryReceipt = function (msg) {
152+
if (msg instanceof Element) {
153+
// See XEP-0184 Message Delivery Receipts
154+
return (msg.querySelector('body') === null) &&
155+
(msg.querySelector('received') !== null);
156+
}
157+
if (msg instanceof Backbone.Model) {
158+
msg = msg.attributes;
159+
}
160+
return msg['received'] && u.isEmptyMessage(msg);
161+
};
162+
151163
u.isHeadlineMessage = function (_converse, message) {
152164
const from_jid = message.getAttribute('from');
153165
if (message.getAttribute('type') === 'headline') {

0 commit comments

Comments
 (0)