Persist resource across sessions

This was somehow lost once we implemented random resource strings
Although its good that initally a random resource is chosen, it
still should persist across sessions.

This helps to kill zombie client connections on the server because
most servers kill the old session once a new with the same resource
connects

Also dont notify the user about resource conflicts if no custom
resource is set. We should not expect users to know about resources
and what they are used for as long as possible.
This commit is contained in:
Philipp Hörist 2017-11-20 18:10:51 +01:00
parent c45d0f5b27
commit 1c895e8983
2 changed files with 9 additions and 0 deletions

View File

@ -191,6 +191,7 @@ class CommonConnection:
'hostname': socket.gethostname(),
'rand': rand
})
app.config.set_per('accounts', self.name, 'resource', resource)
return resource
def dispatch(self, event, data):

View File

@ -1162,10 +1162,18 @@ class Interface:
account = obj.conn.name
conn = obj.conn
self.roster.send_status(account, 'offline', conn.status)
def on_ok(new_resource):
app.config.set_per('accounts', account, 'resource', new_resource)
self.roster.send_status(account, conn.old_show, conn.status)
proposed_resource = conn.server_resource
if proposed_resource.startswith('gajim.'):
# Dont notify the user about resource change if he didnt set
# a custom resource
on_ok('gajim.$rand')
return
proposed_resource += app.config.get('gc_proposed_nick_char')
dlg = dialogs.ResourceConflictDialog(_('Resource Conflict'),
_('You are already connected to this account with the same '