Move 'agent-removed' handler into Gateway module

This commit is contained in:
Philipp Hörist 2019-01-03 09:19:10 +01:00
parent f3d5babc65
commit 0441ccd4e9
2 changed files with 7 additions and 17 deletions

View File

@ -265,25 +265,8 @@ class ConnectionHandlers(ConnectionSocks5Bytestream,
app.nec.register_incoming_event(StreamConflictReceivedEvent) app.nec.register_incoming_event(StreamConflictReceivedEvent)
app.nec.register_incoming_event(NotificationEvent) app.nec.register_incoming_event(NotificationEvent)
app.ged.register_event_handler('agent-removed', ged.CORE,
self._nec_agent_removed)
def cleanup(self): def cleanup(self):
ConnectionHandlersBase.cleanup(self) ConnectionHandlersBase.cleanup(self)
app.ged.remove_event_handler('agent-removed', ged.CORE,
self._nec_agent_removed)
def _nec_agent_removed(self, obj):
if obj.conn.name != self.name:
return
for jid in obj.jid_list:
log.debug('Removing contact %s due to unregistered transport %s',
jid, obj.agent)
self.get_module('Presence').unsubscribe(jid)
# Transport contacts can't have 2 resources
if jid in app.to_be_removed[self.name]:
# This way we'll really remove it
app.to_be_removed[self.name].remove(jid)
def discover_ft_proxies(self): def discover_ft_proxies(self):
cfg_proxies = app.config.get_per('accounts', self.name, cfg_proxies = app.config.get_per('accounts', self.name,

View File

@ -51,6 +51,13 @@ class Gateway:
for jid in app.contacts.get_jid_list(self._account): for jid in app.contacts.get_jid_list(self._account):
if jid.endswith('@' + agent): if jid.endswith('@' + agent):
jid_list.append(jid) jid_list.append(jid)
log.info('Removing contact %s due to unregistered transport %s',
jid, agent)
self._con.get_module('Presence').unsubscribe(jid)
# Transport contacts can't have 2 resources
if jid in app.to_be_removed[self._account]:
# This way we'll really remove it
app.to_be_removed[self._account].remove(jid)
app.nec.push_incoming_event( app.nec.push_incoming_event(
NetworkEvent('agent-removed', NetworkEvent('agent-removed',