diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-13 22:03:54 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-13 22:03:54 +0200 |
commit | 9c053dce8d5d9ad58b0e4646747ce51db2a443b3 (patch) | |
tree | 5f449f97297086b571ea01c079cc9f58a7f108b3 /src | |
parent | def2ca9e405e048b61f834cc180c79340c638257 (diff) |
make receipt handling work with out of order receipts
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/MessageParser.java | 6 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/MessageArchiveService.java | 15 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index 33ef59ef1..0f8e23aa6 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -804,7 +804,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece String id = received.getAttribute("id"); if (packet.fromAccount(account)) { if (query != null && id != null && packet.getTo() != null) { - query.pendingReceiptRequests.remove(new ReceiptRequest(packet.getTo(), id)); + query.removePendingReceiptRequest(new ReceiptRequest(packet.getTo(), id)); } } else { mXmppConnectionService.markMessage(account, from.asBareJid(), received.getAttribute("id"), Message.STATUS_SEND_RECEIVED); @@ -899,9 +899,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece packet.getType()); mXmppConnectionService.sendMessagePacket(account, receipt); } - } else { + } else { //just catchup?? if (request) { - query.pendingReceiptRequests.add(new ReceiptRequest(packet.getFrom(), packet.getId())); + query.addPendingReceiptRequest(new ReceiptRequest(packet.getFrom(), packet.getId())); } } } diff --git a/src/main/java/de/pixart/messenger/services/MessageArchiveService.java b/src/main/java/de/pixart/messenger/services/MessageArchiveService.java index 7158c3b1f..a20c7fc49 100644 --- a/src/main/java/de/pixart/messenger/services/MessageArchiveService.java +++ b/src/main/java/de/pixart/messenger/services/MessageArchiveService.java @@ -323,6 +323,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { private void processPostponed(Query query) { query.account.getAxolotlService().processPostponed(); + query.pendingReceiptRequests.removeAll(query.receiptRequests); Log.d(Config.LOGTAG, query.getAccount().getJid().asBareJid() + ": found " + query.pendingReceiptRequests.size() + " pending receipt requests"); Iterator<ReceiptRequest> iterator = query.pendingReceiptRequests.iterator(); while (iterator.hasNext()) { @@ -359,7 +360,8 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } public class Query { - public HashSet<ReceiptRequest> pendingReceiptRequests = new HashSet<>(); + private HashSet<ReceiptRequest> pendingReceiptRequests = new HashSet<>(); + private HashSet<ReceiptRequest> receiptRequests = new HashSet<>(); private int totalCount = 0; private int actualCount = 0; private int actualInThisQuery = 0; @@ -398,11 +400,22 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { query.totalCount = totalCount; query.actualCount = actualCount; query.pendingReceiptRequests = pendingReceiptRequests; + query.receiptRequests = receiptRequests; query.callback = callback; query.catchup = catchup; return query; } + public void removePendingReceiptRequest(ReceiptRequest receiptRequest) { + if (!this.pendingReceiptRequests.remove(receiptRequest)) { + this.receiptRequests.add(receiptRequest); + } + } + + public void addPendingReceiptRequest(ReceiptRequest receiptRequest) { + this.pendingReceiptRequests.add(receiptRequest); + } + public boolean isLegacy() { if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) { return account.getXmppConnection().getFeatures().mamLegacy(); |