From 85fcb55bd97d91e893a4977a350a4f43872be9b4 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Sun, 29 Jan 2017 11:08:45 +0100 Subject: [PATCH] Fix roster handling of outgoing 'unavailable' presence make sure that the 'to' attribute is not set, as otherwhise the listener would also be invoked e.g. when the user leaves a MUC. --- .../src/main/java/org/jivesoftware/smack/roster/Roster.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java index 71d01fa42..d3f29d178 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java @@ -46,9 +46,11 @@ import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotLoggedInException; import org.jivesoftware.smack.XMPPConnectionRegistry; import org.jivesoftware.smack.XMPPException.XMPPErrorException; +import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.PresenceTypeFilter; import org.jivesoftware.smack.filter.StanzaFilter; import org.jivesoftware.smack.filter.StanzaTypeFilter; +import org.jivesoftware.smack.filter.ToMatchesFilter; import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ.Type; @@ -124,6 +126,8 @@ public final class Roster extends Manager { private static final StanzaFilter PRESENCE_PACKET_FILTER = StanzaTypeFilter.PRESENCE; + private static final StanzaFilter OUTGOING_USER_UNAVAILABLE_PRESENCE = new AndFilter(PresenceTypeFilter.UNAVAILABLE, ToMatchesFilter.MATCH_NO_TO_SET); + private static boolean rosterLoadedAtLoginDefault = true; /** @@ -326,7 +330,7 @@ public final class Roster extends Manager { // state). setOfflinePresences(); } - }, PresenceTypeFilter.UNAVAILABLE); + }, OUTGOING_USER_UNAVAILABLE_PRESENCE); // If the connection is already established, call reload if (connection.isAuthenticated()) {