diff options
Diffstat (limited to 'sleekxmpp/roster')
-rw-r--r-- | sleekxmpp/roster/__init__.py | 1 | ||||
-rw-r--r-- | sleekxmpp/roster/item.py | 4 | ||||
-rw-r--r-- | sleekxmpp/roster/multi.py | 14 | ||||
-rw-r--r-- | sleekxmpp/roster/single.py | 20 |
4 files changed, 25 insertions, 14 deletions
diff --git a/sleekxmpp/roster/__init__.py b/sleekxmpp/roster/__init__.py index 4335d367..18b380c9 100644 --- a/sleekxmpp/roster/__init__.py +++ b/sleekxmpp/roster/__init__.py @@ -6,7 +6,6 @@ See the file LICENSE for copying permission. """ -from sleekxmpp.xmlstream import JID from sleekxmpp.roster.item import RosterItem from sleekxmpp.roster.single import RosterNode from sleekxmpp.roster.multi import Roster diff --git a/sleekxmpp/roster/item.py b/sleekxmpp/roster/item.py index 6e9c0d01..ae194e0a 100644 --- a/sleekxmpp/roster/item.py +++ b/sleekxmpp/roster/item.py @@ -479,11 +479,11 @@ class RosterItem(object): self.xmpp.event('roster_subscription_removed', presence) def handle_probe(self, presence): - if self['to']: + if self['from']: self.send_last_presence() if self['pending_out']: self.subscribe() - if not self['to']: + if not self['from']: self._unsubscribed() def reset(self): diff --git a/sleekxmpp/roster/multi.py b/sleekxmpp/roster/multi.py index 9a04aebb..5d070ec8 100644 --- a/sleekxmpp/roster/multi.py +++ b/sleekxmpp/roster/multi.py @@ -94,10 +94,12 @@ class Roster(object): Arguments: key -- Return the roster for this JID. """ - if isinstance(key, JID): - key = key.bare if key is None: - key = self.xmpp.boundjid.bare + key = self.xmpp.boundjid + if not isinstance(key, JID): + key = JID(key) + key = key.bare + if key not in self._rosters: self.add(key) self._rosters[key].auto_authorize = self.auto_authorize @@ -119,8 +121,10 @@ class Roster(object): Arguments: node -- The JID for the new roster node. """ - if isinstance(node, JID): - node = node.bare + if not isinstance(node, JID): + node = JID(node) + + node = node.bare if node not in self._rosters: self._rosters[node] = RosterNode(self.xmpp, node, self.db) diff --git a/sleekxmpp/roster/single.py b/sleekxmpp/roster/single.py index f8c9c781..e9ce4f21 100644 --- a/sleekxmpp/roster/single.py +++ b/sleekxmpp/roster/single.py @@ -89,8 +89,11 @@ class RosterNode(object): A new item entry will be created if one does not already exist. """ - if isinstance(key, JID): - key = key.bare + if key is None: + key = JID('') + if not isinstance(key, JID): + key = JID(key) + key = key.bare if key not in self._jids: self.add(key, save=True) return self._jids[key] @@ -101,8 +104,11 @@ class RosterNode(object): To remove an item from the server, use the remove() method. """ - if isinstance(key, JID): - key = key.bare + if key is None: + key = JID('') + if not isinstance(key, JID): + key = JID(key) + key = key.bare if key in self._jids: del self._jids[key] @@ -231,8 +237,7 @@ class RosterNode(object): if not self.xmpp.is_component: return self.update(jid, subscription='remove') - def update(self, jid, name=None, subscription=None, groups=[], - block=True, timeout=None, callback=None): + def update(self, jid, name=None, subscription=None, groups=None, block=True, timeout=None, callback=None): """ Update a JID's subscription information. @@ -252,6 +257,9 @@ class RosterNode(object): Will be executed when the roster is received. Implies block=False. """ + if not groups: + groups = [] + self[jid]['name'] = name self[jid]['groups'] = groups self[jid].save() |