diff options
author | Philipp Hörist <forenjunkie@chello.at> | 2018-05-18 19:20:06 +0300 |
---|---|---|
committer | Philipp Hörist <forenjunkie@chello.at> | 2018-05-19 10:49:14 +0300 |
commit | 56067cfdc9c52432466fbbe00c58320702521039 (patch) | |
tree | ae230c779aaaa4c9cd55a42015425c0edb79f3b7 | |
parent | 71648f925acdfc7721fbe987ce97d2b8b0fbafde (diff) |
Init Roster after stream management resume
nbxmpp deletes the roster object on disconnect. Init the roster from db
again on resume.
Fixes #8296
-rw-r--r-- | gajim/common/connection.py | 25 | ||||
-rw-r--r-- | 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 427734475..6161cebea 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -1852,6 +1852,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) @@ -2550,16 +2552,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, + request=not resume) + if resume: + self._init_roster_from_db() + else: + self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, ) - iq_id = self.connection.initRoster(version=version) - 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 13cf4e916..9f453f6a5 100644 --- a/gajim/common/connection_handlers.py +++ b/gajim/common/connection_handlers.py @@ -1497,10 +1497,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 |