| ... |
... |
@@ -34,7 +34,7 @@ def unsubscribe(self, agent): |
|
34
|
34
|
|
|
35
|
35
|
self._con.connection.SendAndCallForResponse(
|
|
36
|
36
|
iq, self._on_unsubscribe_result)
|
|
37
|
|
- self._con.get_module('Roster').del_item(agent)
|
|
|
37
|
+ self._con.get_module('Roster').delete_item(agent)
|
|
38
|
38
|
|
|
39
|
39
|
def _on_unsubscribe_result(self, _nbxmpp_client, stanza):
|
|
40
|
40
|
if not nbxmpp.isResultNode(stanza):
|
| ... |
... |
@@ -43,16 +43,19 @@ def _on_unsubscribe_result(self, _nbxmpp_client, stanza): |
|
43
|
43
|
|
|
44
|
44
|
agent = stanza.getFrom().bare
|
|
45
|
45
|
jid_list = []
|
|
46
|
|
- for jid in app.contacts.get_jid_list(self._account):
|
|
47
|
|
- if jid.endswith('@' + agent):
|
|
48
|
|
- jid_list.append(jid)
|
|
49
|
|
- self._log.info('Removing contact %s due to'
|
|
50
|
|
- ' unregistered transport %s', jid, agent)
|
|
51
|
|
- self._con.get_module('Presence').unsubscribe(jid)
|
|
|
46
|
+ for contact in self._client.get_module('Roster').iter_contacts:
|
|
|
47
|
+ if contact.jid.domain == agent:
|
|
|
48
|
+ jid_list.append(contact.jid)
|
|
|
49
|
+ self._log.info(
|
|
|
50
|
+ 'Removing contact %s due to unregistered transport %s',
|
|
|
51
|
+ contact.jid,
|
|
|
52
|
+ agent)
|
|
|
53
|
+ self._con.get_module('Presence').unsubscribe(contact.jid)
|
|
|
54
|
+
|
|
52
|
55
|
# Transport contacts can't have 2 resources
|
|
53
|
|
- if jid in app.to_be_removed[self._account]:
|
|
|
56
|
+ if contact.jid in app.to_be_removed[self._account]:
|
|
54
|
57
|
# This way we'll really remove it
|
|
55
|
|
- app.to_be_removed[self._account].remove(jid)
|
|
|
58
|
+ app.to_be_removed[self._account].remove(contact.jid)
|
|
56
|
59
|
|
|
57
|
60
|
app.nec.push_incoming_event(
|
|
58
|
61
|
NetworkEvent('agent-removed',
|