mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
use actual message timestamp instead of delay when updating last seen. fixes #1618
This commit is contained in:
parent
58d213f291
commit
73e2389eee
@ -11,6 +11,7 @@ import eu.siacs.conversations.entities.Contact;
|
|||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
import eu.siacs.conversations.xmpp.stanzas.AbstractStanza;
|
||||||
|
|
||||||
public abstract class AbstractParser {
|
public abstract class AbstractParser {
|
||||||
|
|
||||||
@ -47,14 +48,13 @@ public abstract class AbstractParser {
|
|||||||
return dateFormat.parse(timestamp);
|
return dateFormat.parse(timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateLastseen(final Element packet, final Account account, final boolean presenceOverwrite) {
|
protected void updateLastseen(final AbstractStanza packet, final Account account, final boolean presenceOverwrite) {
|
||||||
updateLastseen(packet, account, packet.getAttributeAsJid("from"), presenceOverwrite);
|
updateLastseen(getTimestamp(packet), account, packet.getFrom(), presenceOverwrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateLastseen(final Element packet, final Account account, final Jid from, final boolean 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 String presence = from == null || from.isBareJid() ? "" : from.getResourcepart();
|
||||||
final Contact contact = account.getRoster().getContact(from);
|
final Contact contact = account.getRoster().getContact(from);
|
||||||
final long timestamp = getTimestamp(packet);
|
|
||||||
if (timestamp >= contact.lastseen.time) {
|
if (timestamp >= contact.lastseen.time) {
|
||||||
contact.lastseen.time = timestamp;
|
contact.lastseen.time = timestamp;
|
||||||
if (!presence.isEmpty() && presenceOverwrite) {
|
if (!presence.isEmpty() && presenceOverwrite) {
|
||||||
|
@ -382,13 +382,14 @@ public class MessageParser extends AbstractParser implements
|
|||||||
Jid trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart.getResourcepart());
|
Jid trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart.getResourcepart());
|
||||||
message.setTrueCounterpart(trueCounterpart);
|
message.setTrueCounterpart(trueCounterpart);
|
||||||
if (trueCounterpart != null) {
|
if (trueCounterpart != null) {
|
||||||
updateLastseen(packet,account,trueCounterpart,false);
|
updateLastseen(timestamp, account, trueCounterpart, false);
|
||||||
}
|
}
|
||||||
if (!isTypeGroupChat) {
|
if (!isTypeGroupChat) {
|
||||||
message.setType(Message.TYPE_PRIVATE);
|
message.setType(Message.TYPE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
updateLastseen(timestamp, account, packet.getFrom(), true);
|
||||||
}
|
}
|
||||||
updateLastseen(packet, account, true);
|
|
||||||
boolean checkForDuplicates = query != null
|
boolean checkForDuplicates = query != null
|
||||||
|| (isTypeGroupChat && packet.hasChild("delay","urn:xmpp:delay"))
|
|| (isTypeGroupChat && packet.hasChild("delay","urn:xmpp:delay"))
|
||||||
|| message.getType() == Message.TYPE_PRIVATE;
|
|| message.getType() == Message.TYPE_PRIVATE;
|
||||||
@ -498,7 +499,7 @@ public class MessageParser extends AbstractParser implements
|
|||||||
mXmppConnectionService.markRead(conversation);
|
mXmppConnectionService.markRead(conversation);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateLastseen(packet, account, true);
|
updateLastseen(timestamp, account, packet.getFrom(), true);
|
||||||
final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), displayed.getAttribute("id"), Message.STATUS_SEND_DISPLAYED);
|
final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), displayed.getAttribute("id"), Message.STATUS_SEND_DISPLAYED);
|
||||||
Message message = displayedMessage == null ? null : displayedMessage.prev();
|
Message message = displayedMessage == null ? null : displayedMessage.prev();
|
||||||
while (message != null
|
while (message != null
|
||||||
|
Loading…
Reference in New Issue
Block a user