diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-12-17 06:59:58 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-12-17 06:59:58 +0100 |
commit | 3f6638cb649b650fbf0217d8a060bf149a9b886f (patch) | |
tree | ae806c18bdbfd7683a0f033d25493b5d04f08978 | |
parent | e2f50ab8558a32ff54b6c6c80da319b4a396e173 (diff) |
properly count mam messages
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/MessageParser.java | 10 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/MessageArchiveService.java | 7 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index e55a4a288..a395be78a 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -278,6 +278,10 @@ public class MessageParser extends AbstractParser implements if (result == null ) { return null; } + final MessageArchiveService.Query query = this.mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid")); + if (query!=null) { + query.incrementTotalCount(); + } final Element forwarded = result.findChild("forwarded","urn:xmpp:forward:0"); if (forwarded == null) { return null; @@ -304,7 +308,6 @@ public class MessageParser extends AbstractParser implements final long timestamp = getTimestamp(forwarded); final Jid to = message.getAttributeAsJid("to"); final Jid from = message.getAttributeAsJid("from"); - final MessageArchiveService.Query query = this.mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid")); Jid counterpart; int status; Conversation conversation; @@ -324,8 +327,11 @@ public class MessageParser extends AbstractParser implements finishedMessage.setCounterpart(counterpart); finishedMessage.setRemoteMsgId(message.getAttribute("id")); finishedMessage.setServerMsgId(result.getAttribute("id")); + if (conversation.hasDuplicateMessage(finishedMessage)) { + return null; + } if (query!=null) { - query.incrementCount(); + query.incrementMessageCount(); } return finishedMessage; } diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 66a2d48a8..276890271 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -311,11 +311,14 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { return this.account; } - public void incrementCount() { - this.count++; + public void incrementTotalCount() { this.totalCount++; } + public void incrementMessageCount() { + this.count++; + } + public int getTotalCount() { return this.totalCount; } |