diff --git a/src/core/xmpp.py b/src/core/xmpp.py index 310104f1..81083e86 100644 --- a/src/core/xmpp.py +++ b/src/core/xmpp.py @@ -182,8 +182,14 @@ class SatRosterProtocol(xmppim.RosterClientProtocol): 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 @@ class SatRosterProtocol(xmppim.RosterClientProtocol): 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 @@ class SatRosterProtocol(xmppim.RosterClientProtocol): #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 @@ class SatRosterProtocol(xmppim.RosterClientProtocol): 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)