Mercurial > libervia-backend
changeset 1398:f8ecce11a0bc
core (xmmp): keep the roster groups cache synchronised + fixes a log.warning
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 01 Apr 2015 23:56:32 +0200 (2015-04-01) |
parents | 96dd0ae1a850 |
children | 5c3d1d970b94 |
files | src/core/xmpp.py |
diffstat | 1 files changed, 11 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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)