From 38797177c7ec41923daaff4091af50c173418009 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 14 Dec 2017 19:29:23 +0100 Subject: [PATCH] ChatMarkers: parse own account from true counterpart --- .../eu/siacs/conversations/parser/MessageParser.java | 9 +++++---- .../eu/siacs/conversations/ui/ConversationFragment.java | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index b16ecbd47..1bc9b7321 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -746,13 +746,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece if (conversation != null && id != null && sender != null) { Message message = conversation.findMessageWithRemoteId(id, sender); if (message != null) { - if (conversation.getMucOptions().isSelf(counterpart)) { + final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart); + final Jid trueJid = getTrueCounterpart((query != null && query.safeToExtractTrueCounterpart()) ? mucUserElement : null, fallback); + final boolean trueJidMatchesAccount = account.getJid().toBareJid().equals(trueJid == null ? null : trueJid.toBareJid()); + if (trueJidMatchesAccount || conversation.getMucOptions().isSelf(counterpart)) { if (!message.isRead() && (query == null || query.isCatchup())) { //checking if message is unread fixes race conditions with reflections mXmppConnectionService.markRead(conversation); } - } else { - final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart); - Jid trueJid = getTrueCounterpart((query != null && query.safeToExtractTrueCounterpart()) ? mucUserElement : null, fallback); + } else if (!counterpart.isBareJid() && trueJid != null){ ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid); if (message.addReadByMarker(readByMarker)) { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'"); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 2c47b7d16..11142082e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1391,9 +1391,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa state = ChatState.PAUSED; users = conversation.getMucOptions().getUsersWithChatState(state, 5); } - int markersAdded = 0; if (mucOptions.membersOnly() && mucOptions.nonanonymous()) { - //addedMarkers.addAll(ReadByMarker.from(users)); for (int i = this.messageList.size() - 1; i >= 0; --i) { final Set markersForMessage = messageList.get(i).getReadByMarkers(); final List shownMarkers = new ArrayList<>(); @@ -1426,7 +1424,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa statusMessage = null; } if (statusMessage != null) { - ++markersAdded; this.messageList.add(i + 1, statusMessage); } addedMarkers.add(markerForSender);