core (xmmp): keep the roster groups cache synchronised + fixes a log.warning
This commit is contained in:
parent
c1b7c3c027
commit
31e49c0d23
1 changed files with 11 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue