Fix contact removal
This commit is contained in:
parent
9b51377185
commit
33a9f1434f
2 changed files with 18 additions and 12 deletions
|
@ -69,18 +69,10 @@ class Roster(object):
|
|||
"""Set the a Contact value for the bare jid key"""
|
||||
self.contacts[key] = value
|
||||
|
||||
def __delitem__(self, jid):
|
||||
"""Remove a contact from the roster"""
|
||||
def remove(self, jid):
|
||||
"""Send a removal iq to the server"""
|
||||
jid = safeJID(jid).bare
|
||||
contact = self[jid]
|
||||
if not contact:
|
||||
return
|
||||
for group in list(self.groups.values()):
|
||||
group.remove(contact)
|
||||
if not group:
|
||||
del self.groups[group.name]
|
||||
del self.contacts[contact.bare_jid]
|
||||
if jid in self.jids():
|
||||
if self.__node[jid]:
|
||||
try:
|
||||
self.__node[jid].send_presence(ptype='unavailable')
|
||||
self.__node.remove(jid)
|
||||
|
@ -88,6 +80,20 @@ class Roster(object):
|
|||
import traceback
|
||||
log.debug('IqError when removing %s:\n%s', jid, traceback.format_exc())
|
||||
|
||||
def __delitem__(self, jid):
|
||||
"""Remove a contact from the roster view"""
|
||||
jid = safeJID(jid).bare
|
||||
contact = self[jid]
|
||||
if not contact:
|
||||
return
|
||||
del self.contacts[contact.bare_jid]
|
||||
|
||||
for group in list(self.groups.values()):
|
||||
group.remove(contact)
|
||||
if not group:
|
||||
del self.groups[group.name]
|
||||
self.modified()
|
||||
|
||||
def __iter__(self):
|
||||
"""Iterate over the jids of the contacts"""
|
||||
return iter(self.contacts.values())
|
||||
|
|
|
@ -2613,8 +2613,8 @@ class RosterInfoTab(Tab):
|
|||
else:
|
||||
self.core.information('No roster item to remove')
|
||||
return
|
||||
roster.remove(jid)
|
||||
del roster[jid]
|
||||
roster.modified()
|
||||
|
||||
def command_import(self, arg):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue