From b813e3aa9ebb9007d2770f7fdffb2c9393679fdd Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Wed, 4 Mar 2015 15:26:18 +0100 Subject: [PATCH] Return delivery receipts with the same type as the request Message delivery receipts now use the same message type as the corresponding message with the delivery receipt request. --- .../smackx/receipts/DeliveryReceiptManager.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 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 2a6840e3f..946696b1a 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 @@ -156,8 +156,8 @@ public class DeliveryReceiptManager extends Manager { break; } - Message ack = new Message(from, Message.Type.normal); - ack.addExtension(new DeliveryReceipt(packet.getStanzaId())); + final Message messageWithReceiptRequest = (Message) packet; + Message ack = receiptMessageFor(messageWithReceiptRequest); connection.sendPacket(ack); } }, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST); @@ -286,4 +286,17 @@ public class DeliveryReceiptManager extends Manager { public static String addDeliveryReceiptRequest(Message m) { return DeliveryReceiptRequest.addTo(m); } + + /** + * Create and return a new message including a delivery receipt extension for the given message. + * + * @param messageWithReceiptRequest the given message with a receipt request extension. + * @return a new message with a receipt. + * @since 4.1 + */ + public static Message receiptMessageFor(Message messageWithReceiptRequest) { + Message message = new Message(messageWithReceiptRequest.getFrom(), messageWithReceiptRequest.getType()); + message.addExtension(new DeliveryReceipt(messageWithReceiptRequest.getStanzaId())); + return message; + } }