# HG changeset patch # User souliane # Date 1427925392 -7200 # Node ID f8ecce11a0bc6a9f59898bcb84fd3e999c59fe7e # Parent 96dd0ae1a850ce3682e3a247fcadf32139a33026 core (xmmp): keep the roster groups cache synchronised + fixes a log.warning diff -r 96dd0ae1a850 -r f8ecce11a0bc src/core/xmpp.py --- a/src/core/xmpp.py Wed Apr 01 22:07:28 2015 +0200 +++ b/src/core/xmpp.py Wed Apr 01 23:56:32 2015 +0200 @@ -182,8 +182,14 @@ def rosterCb(self, roster): assert roster is not None # FIXME: must be managed with roster versioning self._jids = roster - for roster_item in roster.itervalues(): - self._registerItem(roster_item) + for item in roster.itervalues(): + if not item.subscriptionTo and not item.subscriptionFrom and not item.ask: + #XXX: current behaviour: we don't want contact in our roster list + # if there is no presence subscription + # may change in the future + self.removeItem(item.jid) # FIXME: to be checked + else: + self._registerItem(item) def _registerItem(self, item): """Register item in local cache @@ -194,12 +200,6 @@ log.debug(u"registering item: {}".format(item.jid.full())) if item.entity.resource: log.warning(u"Received a roster item with a resource, this is not common but not restricted by RFC 6121, this case may be not well tested.") - if not item.subscriptionTo and not item.subscriptionFrom and not item.ask: - #XXX: current behaviour: we don't want contact in our roster list - # if there is no presence subscription - # may change in the future - self.removeItem(item.jid) # FIXME: to be checked - return if not item.subscriptionTo: if not item.subscriptionFrom: log.info(_(u"There's no subscription between you and [{}]!").format(item.jid.full())) @@ -240,6 +240,7 @@ #TODO: implement roster versioning (cf RFC 6121 ยง2.6) item = request.item self._jids[item.entity] = item + self._registerItem(item) self.host.bridge.newContact(item.jid.full(), self.getAttributes(item), item.groups, self.parent.profile) def removeReceived(self, request): @@ -259,8 +260,8 @@ if not jids_set: del self._groups[group] except KeyError: - log.warning("there is not cache for the group [%(groups)s] of the removed roster item [%(jid)s]" % - {"group": group, "jid": entity}) + log.warning("there is no cache for the group [%(group)s] of the removed roster item [%(jid)s]" % + {"group": group, "jid": entity}) # then we send the bridge signal self.host.bridge.contactDeleted(entity.full(), self.parent.profile)