diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/parser')
3 files changed, 14 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java index 03f19ed82..c14a7eb0d 100644 --- a/src/main/java/eu/siacs/conversations/parser/AbstractParser.java +++ b/src/main/java/eu/siacs/conversations/parser/AbstractParser.java @@ -51,12 +51,16 @@ public abstract class AbstractParser { return dateFormat.parse(timestamp); } - protected void updateLastseen(long timestamp, final Account account, final Jid from) { - final String presence = from == null || from.isBareJid() ? "" : from.getResourcepart(); - final Contact contact = account.getRoster().getContact(from); + protected void updateLastseen(final AbstractStanza packet, final Account account, final boolean presenceOverwrite) { + updateLastseen(getTimestamp(packet), account, packet.getFrom(), presenceOverwrite); + } + + protected void updateLastseen(long timestamp, final Account account, final Jid from, final boolean presenceOverwrite) { + final String presence = from == null || from.isBareJid() ? "" : from.getResourcepart(); + final Contact contact = account.getRoster().getContact(from); if (timestamp >= contact.lastseen.time) { contact.lastseen.time = timestamp; - if (!presence.isEmpty()) { + if (!presence.isEmpty() && presenceOverwrite) { contact.lastseen.presence = presence; } } diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 79be0bb5c..7ae89c7ef 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -10,7 +10,6 @@ import net.java.otr4j.session.SessionStatus; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Locale; import java.util.Set; import java.util.UUID; @@ -433,11 +432,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece if (conversationMultiMode) { Jid trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart); message.setTrueCounterpart(trueCounterpart); + if (trueCounterpart != null) { + updateLastseen(timestamp, account, trueCounterpart, false); + } if (!isTypeGroupChat) { message.setType(Message.TYPE_PRIVATE); } } else { - updateLastseen(timestamp, account, from); + updateLastseen(timestamp, account, packet.getFrom(), true); } if (replacementId != null && mXmppConnectionService.allowMessageCorrection()) { @@ -599,7 +601,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece mXmppConnectionService.markRead(conversation); } } else { - updateLastseen(timestamp, account, from); + updateLastseen(timestamp, account, packet.getFrom(), true); final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), displayed.getAttribute("id"), Message.STATUS_SEND_DISPLAYED); Message message = displayedMessage == null ? null : displayedMessage.prev(); while (message != null diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index b5718b612..89f294e90 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -5,7 +5,6 @@ import android.util.Log; import java.util.ArrayList; import java.util.List; - import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.PgpEngine; import eu.siacs.conversations.entities.Account; @@ -214,6 +213,7 @@ public class PresenceParser extends AbstractParser implements contact.setPgpKeyId(pgp.fetchKeyId(account, msg, x.getContent())); } boolean online = sizeBefore < contact.getPresences().size(); + updateLastseen(packet, account, false); mXmppConnectionService.onContactStatusChanged.onContactStatusChanged(contact, online); } else if (type.equals("unavailable")) { if (from.isBareJid()) { |