core (xmpp): update the cache for a contact group when a contact is removed from it
This commit is contained in:
parent
2273421745
commit
f78804cce5
1 changed files with 10 additions and 0 deletions
|
|
@ -181,6 +181,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
|
||||||
|
|
||||||
def rosterCb(self, roster):
|
def rosterCb(self, roster):
|
||||||
assert roster is not None # FIXME: must be managed with roster versioning
|
assert roster is not None # FIXME: must be managed with roster versioning
|
||||||
|
self._groups.clear()
|
||||||
self._jids = roster
|
self._jids = roster
|
||||||
for item in roster.itervalues():
|
for item in roster.itervalues():
|
||||||
if not item.subscriptionTo and not item.subscriptionFrom and not item.ask:
|
if not item.subscriptionTo and not item.subscriptionFrom and not item.ask:
|
||||||
|
|
@ -239,6 +240,15 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
|
||||||
def setReceived(self, request):
|
def setReceived(self, request):
|
||||||
#TODO: implement roster versioning (cf RFC 6121 §2.6)
|
#TODO: implement roster versioning (cf RFC 6121 §2.6)
|
||||||
item = request.item
|
item = request.item
|
||||||
|
try: # update the cache for the groups the contact has been removed from
|
||||||
|
left_groups = set(self._jids[item.entity].groups).difference(item.groups)
|
||||||
|
for group in left_groups:
|
||||||
|
jids_set = self._groups[group]
|
||||||
|
jids_set.remove(item.entity)
|
||||||
|
if not jids_set:
|
||||||
|
del self._groups[group]
|
||||||
|
except KeyError:
|
||||||
|
pass # no previous item registration (or it's been cleared)
|
||||||
self._jids[item.entity] = item
|
self._jids[item.entity] = item
|
||||||
self._registerItem(item)
|
self._registerItem(item)
|
||||||
self.host.bridge.newContact(item.entity.full(), self.getAttributes(item), item.groups, self.parent.profile)
|
self.host.bridge.newContact(item.entity.full(), self.getAttributes(item), item.groups, self.parent.profile)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue