From 72c7137ff15374a5307fcb0ae89b2be85474aef8 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 14 Dec 2015 11:34:18 +0100 Subject: [PATCH] Don't request receipts for messages without a body SMACK-709 --- .../smackx/receipts/DeliveryReceiptManager.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java index 82dbd490f..67888eb7b 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/receipts/DeliveryReceiptManager.java @@ -32,6 +32,7 @@ import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.MessageTypeFilter; +import org.jivesoftware.smack.filter.MessageWithBodiesFilter; import org.jivesoftware.smack.filter.NotFilter; import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaExtensionFilter; @@ -244,13 +245,17 @@ public class DeliveryReceiptManager extends Manager { /** * A filter for stanzas to request delivery receipts for. Notably those are message stanzas of type normal, chat or - * headline, which do notcontain a delivery receipt, i.e. are ack messages. + * headline, which do notcontain a delivery receipt, i.e. are ack messages, and have a body extension. * * @see XEP-184 ยง 5.4 Ack Messages */ private static final StanzaFilter MESSAGES_TO_REQUEST_RECEIPTS_FOR = new AndFilter( - MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE, new NotFilter(new StanzaExtensionFilter( - DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE))); + // @formatter:off + MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE, + new NotFilter(new StanzaExtensionFilter(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)), + MessageWithBodiesFilter.INSTANCE + ); + // @formatter:on private static final StanzaListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new StanzaListener() { @Override @@ -261,7 +266,9 @@ public class DeliveryReceiptManager extends Manager { }; /** - * Enables automatic requests of delivery receipts for outgoing messages of type 'normal', 'chat' or 'headline. + * Enables automatic requests of delivery receipts for outgoing messages of + * {@link Message.Type#normal}, {@link Message.Type#chat} or {@link Message.Type#headline}, and + * with a {@link Message.Body} extension. * * @since 4.1 * @see #dontAutoAddDeliveryReceiptRequests()