properly count mam messages

This commit is contained in:
iNPUTmice 2014-12-17 06:59:58 +01:00
parent e2f50ab855
commit 3f6638cb64
2 changed files with 13 additions and 4 deletions

View file

@ -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;
}

View file

@ -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;
}