From 117036b872d0afef2ca241bea9d319df1472e52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Fri, 18 May 2018 18:20:06 +0200 Subject: [PATCH] Init Roster after stream management resume nbxmpp deletes the roster object on disconnect. Init the roster from db again on resume. Fixes #8296 --- gajim/common/connection.py | 25 ++++++++++++++++++------- gajim/common/connection_handlers.py | 5 +---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/gajim/common/connection.py b/gajim/common/connection.py index 68dc563ac..5416ac496 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -1837,6 +1837,8 @@ class Connection(CommonConnection, ConnectionHandlers): our_server = app.config.get_per('accounts', self.name, 'hostname') self.discoverInfo(our_jid, id_prefix='Gajim_') self.discoverInfo(our_server, id_prefix='Gajim_') + else: + self.request_roster(resume=True) self.sm.resuming = False # back to previous state # Discover Stun server(s) @@ -2535,16 +2537,25 @@ class Connection(CommonConnection, ConnectionHandlers): iq3.addChild(name='meta', attrs=dict_) self.connection.send(iq) - def request_roster(self): + def request_roster(self, resume=False): version = None features = self.connection.Dispatcher.Stream.features - if features and features.getTag('ver', - namespace=nbxmpp.NS_ROSTER_VER): - version = app.config.get_per('accounts', self.name, - 'roster_version') + if features and features.getTag('ver', namespace=nbxmpp.NS_ROSTER_VER): + version = app.config.get_per( + 'accounts', self.name, 'roster_version') - iq_id = self.connection.initRoster(version=version) - self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, ) + iq_id = self.connection.initRoster(version=version, + request=not resume) + if resume: + self._init_roster_from_db() + else: + self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, ) + + def _init_roster_from_db(self): + account_jid = app.get_jid_from_account(self.name) + roster_data = app.logger.get_roster(account_jid) + roster = self.connection.getRoster(force=True) + roster.setRaw(roster_data) def send_agent_status(self, agent, ptype): if not app.account_is_connected(self.name): diff --git a/gajim/common/connection_handlers.py b/gajim/common/connection_handlers.py index 657067170..8f528eaea 100644 --- a/gajim/common/connection_handlers.py +++ b/gajim/common/connection_handlers.py @@ -1546,10 +1546,7 @@ ConnectionHTTPUpload): elif self.awaiting_answers[id_][0] == ROSTER_ARRIVED: if iq_obj.getType() == 'result': if not iq_obj.getTag('query'): - account_jid = app.get_jid_from_account(self.name) - roster_data = app.logger.get_roster(account_jid) - roster = self.connection.getRoster(force=True) - roster.setRaw(roster_data) + self._init_roster_from_db() self._getRoster() elif iq_obj.getType() == 'error': self.roster_supported = False