make receipt handling work with out of order receipts
This commit is contained in:
parent
2e8cc12ada
commit
fe8f0bd7f0
|
@ -692,7 +692,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
String id = received.getAttribute("id");
|
String id = received.getAttribute("id");
|
||||||
if (packet.fromAccount(account)) {
|
if (packet.fromAccount(account)) {
|
||||||
if (query != null && id != null && packet.getTo() != null) {
|
if (query != null && id != null && packet.getTo() != null) {
|
||||||
query.pendingReceiptRequests.remove(new ReceiptRequest(packet.getTo(),id));
|
query.removePendingReceiptRequest(new ReceiptRequest(packet.getTo(),id));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mXmppConnectionService.markMessage(account, from.asBareJid(), received.getAttribute("id"), Message.STATUS_SEND_RECEIVED);
|
mXmppConnectionService.markMessage(account, from.asBareJid(), received.getAttribute("id"), Message.STATUS_SEND_RECEIVED);
|
||||||
|
@ -785,9 +785,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
packet.getType());
|
packet.getType());
|
||||||
mXmppConnectionService.sendMessagePacket(account, receipt);
|
mXmppConnectionService.sendMessagePacket(account, receipt);
|
||||||
}
|
}
|
||||||
} else {
|
} else { //just catchup??
|
||||||
if (request) {
|
if (request) {
|
||||||
query.pendingReceiptRequests.add(new ReceiptRequest(packet.getFrom(),packet.getId()));
|
query.addPendingReceiptRequest(new ReceiptRequest(packet.getFrom(),packet.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,6 +324,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
|
|
||||||
private void processPostponed(Query query) {
|
private void processPostponed(Query query) {
|
||||||
query.account.getAxolotlService().processPostponed();
|
query.account.getAxolotlService().processPostponed();
|
||||||
|
query.pendingReceiptRequests.removeAll(query.receiptRequests);
|
||||||
Log.d(Config.LOGTAG, query.getAccount().getJid().asBareJid() + ": found " + query.pendingReceiptRequests.size() + " pending receipt requests");
|
Log.d(Config.LOGTAG, query.getAccount().getJid().asBareJid() + ": found " + query.pendingReceiptRequests.size() + " pending receipt requests");
|
||||||
Iterator<ReceiptRequest> iterator = query.pendingReceiptRequests.iterator();
|
Iterator<ReceiptRequest> iterator = query.pendingReceiptRequests.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -360,7 +361,8 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Query {
|
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 totalCount = 0;
|
||||||
private int actualCount = 0;
|
private int actualCount = 0;
|
||||||
private int actualInThisQuery = 0;
|
private int actualInThisQuery = 0;
|
||||||
|
@ -399,11 +401,22 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
||||||
query.totalCount = totalCount;
|
query.totalCount = totalCount;
|
||||||
query.actualCount = actualCount;
|
query.actualCount = actualCount;
|
||||||
query.pendingReceiptRequests = pendingReceiptRequests;
|
query.pendingReceiptRequests = pendingReceiptRequests;
|
||||||
|
query.receiptRequests = receiptRequests;
|
||||||
query.callback = callback;
|
query.callback = callback;
|
||||||
query.catchup = catchup;
|
query.catchup = catchup;
|
||||||
return query;
|
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() {
|
public boolean isLegacy() {
|
||||||
if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) {
|
if (conversation == null || conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||||
return account.getXmppConnection().getFeatures().mamLegacy();
|
return account.getXmppConnection().getFeatures().mamLegacy();
|
||||||
|
|
Loading…
Reference in New Issue