From e9b514548b54affed48522a2d61248bf7aee53e1 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 17 Feb 2019 21:54:38 +0100 Subject: [PATCH] Filter error messages in DeliveryReceiptManager --- .../smackx/receipts/DeliveryReceiptManager.java | 16 ++++++++++++---- 1 file changed, 12 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 dbfd61436..c310ceb25 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 @@ -1,6 +1,6 @@ /** * - * Copyright 2013-2014 Georg Lukas, 2015 Florian Schmaus + * Copyright 2013-2014 Georg Lukas, 2015-2019 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,8 +74,16 @@ import org.jxmpp.jid.Jid; */ public final class DeliveryReceiptManager extends Manager { - private static final StanzaFilter MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST = new AndFilter(StanzaTypeFilter.MESSAGE, - new StanzaExtensionFilter(new DeliveryReceiptRequest())); + /** + * Filters all non-error messages with receipt requests. + * See XEP-0184 § 5. "A sender could request receipts + * on any non-error content message (chat, groupchat, headline, or normal)…" + */ + private static final StanzaFilter NON_ERROR_GROUPCHAT_MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST = new AndFilter( + StanzaTypeFilter.MESSAGE, + new StanzaExtensionFilter(new DeliveryReceiptRequest()), + new NotFilter(MessageTypeFilter.ERROR)); + private static final StanzaFilter MESSAGES_WITH_DELIVERY_RECEIPT = new AndFilter(StanzaTypeFilter.MESSAGE, new StanzaExtensionFilter(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE)); @@ -175,7 +183,7 @@ public final class DeliveryReceiptManager extends Manager { } connection.sendStanza(ack); } - }, MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST); + }, NON_ERROR_GROUPCHAT_MESSAGES_WITH_DELIVERY_RECEIPT_REQUEST); } /**