ChatMarkers: parse own account from true counterpart

This commit is contained in:
Daniel Gultsch 2017-12-14 19:29:23 +01:00
parent a6864878ba
commit 38797177c7
2 changed files with 5 additions and 7 deletions

View File

@ -746,13 +746,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (conversation != null && id != null && sender != null) { if (conversation != null && id != null && sender != null) {
Message message = conversation.findMessageWithRemoteId(id, sender); Message message = conversation.findMessageWithRemoteId(id, sender);
if (message != null) { 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 if (!message.isRead() && (query == null || query.isCatchup())) { //checking if message is unread fixes race conditions with reflections
mXmppConnectionService.markRead(conversation); mXmppConnectionService.markRead(conversation);
} }
} else { } else if (!counterpart.isBareJid() && trueJid != null){
final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
Jid trueJid = getTrueCounterpart((query != null && query.safeToExtractTrueCounterpart()) ? mucUserElement : null, fallback);
ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid); ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid);
if (message.addReadByMarker(readByMarker)) { if (message.addReadByMarker(readByMarker)) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'"); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'");

View File

@ -1391,9 +1391,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
state = ChatState.PAUSED; state = ChatState.PAUSED;
users = conversation.getMucOptions().getUsersWithChatState(state, 5); users = conversation.getMucOptions().getUsersWithChatState(state, 5);
} }
int markersAdded = 0;
if (mucOptions.membersOnly() && mucOptions.nonanonymous()) { if (mucOptions.membersOnly() && mucOptions.nonanonymous()) {
//addedMarkers.addAll(ReadByMarker.from(users));
for (int i = this.messageList.size() - 1; i >= 0; --i) { for (int i = this.messageList.size() - 1; i >= 0; --i) {
final Set<ReadByMarker> markersForMessage = messageList.get(i).getReadByMarkers(); final Set<ReadByMarker> markersForMessage = messageList.get(i).getReadByMarkers();
final List<MucOptions.User> shownMarkers = new ArrayList<>(); final List<MucOptions.User> shownMarkers = new ArrayList<>();
@ -1426,7 +1424,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
statusMessage = null; statusMessage = null;
} }
if (statusMessage != null) { if (statusMessage != null) {
++markersAdded;
this.messageList.add(i + 1, statusMessage); this.messageList.add(i + 1, statusMessage);
} }
addedMarkers.add(markerForSender); addedMarkers.add(markerForSender);