fixed read/unread markers

This commit is contained in:
Daniel Gultsch 2015-05-15 11:51:20 +02:00
parent b731995a51
commit eeebebe32a
1 changed files with 9 additions and 10 deletions

View File

@ -181,7 +181,6 @@ public class MessageParser extends AbstractParser implements
final MessagePacket packet; final MessagePacket packet;
Long timestamp = null; Long timestamp = null;
final boolean isForwarded; final boolean isForwarded;
boolean carbon = false; //live carbons or mam-sub
MessageArchiveService.Query query = null; MessageArchiveService.Query query = null;
String serverMsgId = null; String serverMsgId = null;
if (original.fromServer(account)) { if (original.fromServer(account)) {
@ -192,15 +191,14 @@ public class MessageParser extends AbstractParser implements
packet = f != null ? f.first : original; packet = f != null ? f.first : original;
timestamp = f != null ? f.second : null; timestamp = f != null ? f.second : null;
isForwarded = f != null; isForwarded = f != null;
carbon = original.hasChild("received", "urn:xmpp:carbons:2") || original.hasChild("received", "urn:xmpp:carbons:2");
Element fin = packet.findChild("fin", "urn:xmpp:mam:0"); Element fin = original.findChild("fin", "urn:xmpp:mam:0");
if (fin != null) { if (fin != null) {
mXmppConnectionService.getMessageArchiveService().processFin(fin); mXmppConnectionService.getMessageArchiveService().processFin(fin);
return; return;
} }
final Element result = packet.findChild("result","urn:xmpp:mam:0"); final Element result = original.findChild("result","urn:xmpp:mam:0");
if (result != null) { if (result != null) {
query = mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid")); query = mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid"));
if (query != null) { if (query != null) {
@ -307,13 +305,14 @@ public class MessageParser extends AbstractParser implements
query.incrementMessageCount(); query.incrementMessageCount();
} }
conversation.add(message); conversation.add(message);
if (carbon || status == Message.STATUS_RECEIVED) { if (serverMsgId == null) {
if (status == Message.STATUS_SEND) {
mXmppConnectionService.markRead(conversation); mXmppConnectionService.markRead(conversation);
account.activateGracePeriod(); account.activateGracePeriod();
} else if (!isForwarded) { } else {
message.markUnread(); message.markUnread();
} }
}
if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded) { if (mXmppConnectionService.confirmMessages() && remoteMsgId != null && !isForwarded) {
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) { if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {