Init Roster after stream management resume
nbxmpp deletes the roster object on disconnect. Init the roster from db again on resume. Fixes #8296
This commit is contained in:
parent
496bfd312d
commit
117036b872
|
@ -1837,6 +1837,8 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
our_server = app.config.get_per('accounts', self.name, 'hostname')
|
our_server = app.config.get_per('accounts', self.name, 'hostname')
|
||||||
self.discoverInfo(our_jid, id_prefix='Gajim_')
|
self.discoverInfo(our_jid, id_prefix='Gajim_')
|
||||||
self.discoverInfo(our_server, id_prefix='Gajim_')
|
self.discoverInfo(our_server, id_prefix='Gajim_')
|
||||||
|
else:
|
||||||
|
self.request_roster(resume=True)
|
||||||
|
|
||||||
self.sm.resuming = False # back to previous state
|
self.sm.resuming = False # back to previous state
|
||||||
# Discover Stun server(s)
|
# Discover Stun server(s)
|
||||||
|
@ -2535,16 +2537,25 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
iq3.addChild(name='meta', attrs=dict_)
|
iq3.addChild(name='meta', attrs=dict_)
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
|
|
||||||
def request_roster(self):
|
def request_roster(self, resume=False):
|
||||||
version = None
|
version = None
|
||||||
features = self.connection.Dispatcher.Stream.features
|
features = self.connection.Dispatcher.Stream.features
|
||||||
if features and features.getTag('ver',
|
if features and features.getTag('ver', namespace=nbxmpp.NS_ROSTER_VER):
|
||||||
namespace=nbxmpp.NS_ROSTER_VER):
|
version = app.config.get_per(
|
||||||
version = app.config.get_per('accounts', self.name,
|
'accounts', self.name, 'roster_version')
|
||||||
'roster_version')
|
|
||||||
|
|
||||||
iq_id = self.connection.initRoster(version=version)
|
iq_id = self.connection.initRoster(version=version,
|
||||||
self.awaiting_answers[iq_id] = (ROSTER_ARRIVED, )
|
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):
|
def send_agent_status(self, agent, ptype):
|
||||||
if not app.account_is_connected(self.name):
|
if not app.account_is_connected(self.name):
|
||||||
|
|
|
@ -1546,10 +1546,7 @@ ConnectionHTTPUpload):
|
||||||
elif self.awaiting_answers[id_][0] == ROSTER_ARRIVED:
|
elif self.awaiting_answers[id_][0] == ROSTER_ARRIVED:
|
||||||
if iq_obj.getType() == 'result':
|
if iq_obj.getType() == 'result':
|
||||||
if not iq_obj.getTag('query'):
|
if not iq_obj.getTag('query'):
|
||||||
account_jid = app.get_jid_from_account(self.name)
|
self._init_roster_from_db()
|
||||||
roster_data = app.logger.get_roster(account_jid)
|
|
||||||
roster = self.connection.getRoster(force=True)
|
|
||||||
roster.setRaw(roster_data)
|
|
||||||
self._getRoster()
|
self._getRoster()
|
||||||
elif iq_obj.getType() == 'error':
|
elif iq_obj.getType() == 'error':
|
||||||
self.roster_supported = False
|
self.roster_supported = False
|
||||||
|
|
Loading…
Reference in New Issue