1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Don't request receipts for messages without a body

SMACK-709
This commit is contained in:
Florian Schmaus 2015-12-14 11:34:18 +01:00
parent 09364e571c
commit 72c7137ff1

View file

@ -32,6 +32,7 @@ import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.MessageTypeFilter; import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.MessageWithBodiesFilter;
import org.jivesoftware.smack.filter.NotFilter; import org.jivesoftware.smack.filter.NotFilter;
import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.StanzaExtensionFilter; 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 * A filter for stanzas to request delivery receipts for. Notably those are message stanzas of type normal, chat or
* headline, which <b>do not</b>contain a delivery receipt, i.e. are ack messages. * headline, which <b>do not</b>contain a delivery receipt, i.e. are ack messages, and have a body extension.
* *
* @see <a href="http://xmpp.org/extensions/xep-0184.html#when-ack">XEP-184 § 5.4 Ack Messages</a> * @see <a href="http://xmpp.org/extensions/xep-0184.html#when-ack">XEP-184 § 5.4 Ack Messages</a>
*/ */
private static final StanzaFilter MESSAGES_TO_REQUEST_RECEIPTS_FOR = new AndFilter( private static final StanzaFilter MESSAGES_TO_REQUEST_RECEIPTS_FOR = new AndFilter(
MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE, new NotFilter(new StanzaExtensionFilter( // @formatter:off
DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE))); 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() { private static final StanzaListener AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTENER = new StanzaListener() {
@Override @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 * @since 4.1
* @see #dontAutoAddDeliveryReceiptRequests() * @see #dontAutoAddDeliveryReceiptRequests()