use instead of message id for receipt processing

This commit is contained in:
Daniel Gultsch 2020-11-12 13:33:27 +01:00
parent ff13cc2766
commit 5ad054617b
2 changed files with 14 additions and 13 deletions

View file

@ -223,13 +223,13 @@ public class MessageGenerator extends AbstractGenerator {
return packet; return packet;
} }
public MessagePacket received(Account account, MessagePacket originalMessage, ArrayList<String> namespaces, int type) { public MessagePacket received(Account account, final Jid from, final String id, ArrayList<String> namespaces, int type) {
MessagePacket receivedPacket = new MessagePacket(); final MessagePacket receivedPacket = new MessagePacket();
receivedPacket.setType(type); receivedPacket.setType(type);
receivedPacket.setTo(originalMessage.getFrom()); receivedPacket.setTo(from);
receivedPacket.setFrom(account.getJid()); receivedPacket.setFrom(account.getJid());
for (String namespace : namespaces) { for (final String namespace : namespaces) {
receivedPacket.addChild("received", namespace).setAttribute("id", originalMessage.getId()); receivedPacket.addChild("received", namespace).setAttribute("id", id);
} }
receivedPacket.addChild("store", "urn:xmpp:hints"); receivedPacket.addChild("store", "urn:xmpp:hints");
return receivedPacket; return receivedPacket;

View file

@ -660,7 +660,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
&& remoteMsgId != null && remoteMsgId != null
&& !selfAddressed && !selfAddressed
&& !isTypeGroupChat) { && !isTypeGroupChat) {
processMessageReceipts(account, packet, query); processMessageReceipts(account, packet, remoteMsgId, query);
} }
if (replacedMessage.getEncryption() == Message.ENCRYPTION_PGP) { if (replacedMessage.getEncryption() == Message.ENCRYPTION_PGP) {
conversation.getAccount().getPgpDecryptionService().discard(replacedMessage); conversation.getAccount().getPgpDecryptionService().discard(replacedMessage);
@ -746,7 +746,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
&& remoteMsgId != null && remoteMsgId != null
&& !selfAddressed && !selfAddressed
&& !isTypeGroupChat) { && !isTypeGroupChat) {
processMessageReceipts(account, packet, query); processMessageReceipts(account, packet, remoteMsgId, query);
} }
mXmppConnectionService.databaseBackend.createMessage(message); mXmppConnectionService.databaseBackend.createMessage(message);
@ -859,8 +859,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
serverMsgId = extractStanzaId(account, packet); serverMsgId = extractStanzaId(account, packet);
} }
mXmppConnectionService.getJingleConnectionManager().deliverMessage(account, packet.getTo(), packet.getFrom(), child, remoteMsgId, serverMsgId, timestamp); mXmppConnectionService.getJingleConnectionManager().deliverMessage(account, packet.getTo(), packet.getFrom(), child, remoteMsgId, serverMsgId, timestamp);
if (!account.getJid().asBareJid().equals(from.asBareJid())) { if (!account.getJid().asBareJid().equals(from.asBareJid()) && remoteMsgId != null) {
processMessageReceipts(account, packet, query); processMessageReceipts(account, packet, remoteMsgId, query);
} }
} else if (query.isCatchup()) { } else if (query.isCatchup()) {
if ("propose".equals(action)) { if ("propose".equals(action)) {
@ -1045,7 +1045,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} }
} }
private void processMessageReceipts(Account account, MessagePacket packet, MessageArchiveService.Query query) { private void processMessageReceipts(final Account account, final MessagePacket packet, final String remoteMsgId, MessageArchiveService.Query query) {
final boolean markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0"); final boolean markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
final boolean request = packet.hasChild("request", "urn:xmpp:receipts"); final boolean request = packet.hasChild("request", "urn:xmpp:receipts");
if (query == null) { if (query == null) {
@ -1057,15 +1057,16 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
receiptsNamespaces.add("urn:xmpp:receipts"); receiptsNamespaces.add("urn:xmpp:receipts");
} }
if (receiptsNamespaces.size() > 0) { if (receiptsNamespaces.size() > 0) {
MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account, final MessagePacket receipt = mXmppConnectionService.getMessageGenerator().received(account,
packet, packet.getFrom(),
remoteMsgId,
receiptsNamespaces, receiptsNamespaces,
packet.getType()); packet.getType());
mXmppConnectionService.sendMessagePacket(account, receipt); mXmppConnectionService.sendMessagePacket(account, receipt);
} }
} else if (query.isCatchup()) { } else if (query.isCatchup()) {
if (request) { if (request) {
query.addPendingReceiptRequest(new ReceiptRequest(packet.getFrom(), packet.getId())); query.addPendingReceiptRequest(new ReceiptRequest(packet.getFrom(), remoteMsgId));
} }
} }
} }