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

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.
This commit is contained in:
Florian Schmaus 2015-03-04 15:26:18 +01:00
parent 18d9be0099
commit b813e3aa9e

View file

@ -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;
}
}