diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-06-01 20:38:35 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-06-01 20:38:35 +0200 |
commit | 27132079479958d823b01217aaed1420a5ab60b6 (patch) | |
tree | a8b78f7d31fe5f30978256c8b737b526c7ac60d4 /src/main/java/de/pixart/messenger | |
parent | 814f34ba49093534ce88b8824fc74a699cd81938 (diff) |
do not parse delay tag for unavailable presences when it comes form own server
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/AbstractParser.java | 17 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/parser/PresenceParser.java | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/AbstractParser.java b/src/main/java/de/pixart/messenger/parser/AbstractParser.java index 8fd106922..8c33ec25d 100644 --- a/src/main/java/de/pixart/messenger/parser/AbstractParser.java +++ b/src/main/java/de/pixart/messenger/parser/AbstractParser.java @@ -12,6 +12,7 @@ import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.jid.InvalidJidException; import de.pixart.messenger.xmpp.jid.Jid; +import de.pixart.messenger.xmpp.stanzas.AbstractStanza; public abstract class AbstractParser { @@ -22,11 +23,25 @@ public abstract class AbstractParser { } public static Long parseTimestamp(Element element, Long d) { + return parseTimestamp(element, d, false); + } + + public static Long parseTimestamp(Element element, Long d, boolean ignoreCsiAndSm) { long min = Long.MAX_VALUE; boolean returnDefault = true; + final Jid to; + if (ignoreCsiAndSm && element instanceof AbstractStanza) { + to = ((AbstractStanza) element).getTo(); + } else { + to = null; + } for (Element child : element.getChildren()) { if ("delay".equals(child.getName()) && "urn:xmpp:delay".equals(child.getNamespace())) { - String stamp = child.getAttribute("stamp"); + final Jid f = to == null ? null : child.getAttributeAsJid("from"); + if (f != null && (to.toBareJid().equals(f) || to.getDomainpart().equals(f.toString()))) { + continue; + } + final String stamp = child.getAttribute("stamp"); if (stamp != null) { try { min = Math.min(min, AbstractParser.parseTimestamp(stamp)); diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java index a4534439e..c95380085 100644 --- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java +++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java @@ -238,7 +238,7 @@ public class PresenceParser extends AbstractParser implements boolean online = sizeBefore < contact.getPresences().size(); mXmppConnectionService.onContactStatusChanged.onContactStatusChanged(contact, online); } else if (type.equals("unavailable")) { - if (contact.setLastseen(AbstractParser.parseTimestamp(packet))) { + if (contact.setLastseen(AbstractParser.parseTimestamp(packet, 0L, true))) { contact.flagInactive(); } if (from.isBareJid()) { |