1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 09:42:06 +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; break;
} }
Message ack = new Message(from, Message.Type.normal); final Message messageWithReceiptRequest = (Message) packet;
ack.addExtension(new DeliveryReceipt(packet.getStanzaId())); Message ack = receiptMessageFor(messageWithReceiptRequest);
connection.sendPacket(ack); connection.sendPacket(ack);
} }
}, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST); }, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST);
@ -286,4 +286,17 @@ public class DeliveryReceiptManager extends Manager {
public static String addDeliveryReceiptRequest(Message m) { public static String addDeliveryReceiptRequest(Message m) {
return DeliveryReceiptRequest.addTo(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;
}
} }