From 3f6638cb649b650fbf0217d8a060bf149a9b886f Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Wed, 17 Dec 2014 06:59:58 +0100 Subject: properly count mam messages --- src/main/java/eu/siacs/conversations/parser/MessageParser.java | 10 ++++++++-- .../eu/siacs/conversations/services/MessageArchiveService.java | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src/main/java/eu/siacs') diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index e55a4a28..a395be78 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 66a2d48a..27689027 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; } -- cgit v1.2.3