Philipp Hörist pushed to branch master at gajim / gajim
Commits: cc13f14a by lovetox at 2020-03-20T20:20:25+01:00 Client: Correctly set resource for bind
Fixes #10026
- - - - -
2 changed files:
- gajim/common/client.py - gajim/common/helpers.py
Changes:
===================================== gajim/common/client.py ===================================== @@ -35,6 +35,7 @@ from gajim.common.helpers import get_encryption_method from gajim.common.helpers import get_custom_host from gajim.common.helpers import get_user_proxy from gajim.common.helpers import warn_about_plain_connection +from gajim.common.helpers import get_resource
from gajim.common.connection_handlers import ConnectionHandlers from gajim.common.connection_handlers_events import OurShowEvent @@ -116,7 +117,7 @@ class Client(ConnectionHandlers): self.connection = self._client self._client.set_domain(self._hostname) self._client.set_username(self._user) - self._client.set_resource('test') + self._client.set_resource(get_resource(self._account))
custom_host = get_custom_host(self._account) if custom_host is not None:
===================================== gajim/common/helpers.py ===================================== @@ -1565,14 +1565,15 @@ def geo_provider_from_location(lat, lon):
def get_resource(account): resource = app.config.get_per('accounts', account, 'resource') - # All valid resource substitution strings should be added to this hash. - if resource: - rand = ''.join(random.choice( - string.ascii_uppercase + string.digits) for _ in range(8)) - resource = Template(resource).safe_substitute( - {'hostname': socket.gethostname(), - 'rand': rand}) - app.config.set_per('accounts', account, 'resource', resource) + if not resource: + return None + + rand = ''.join(random.choice( + string.ascii_uppercase + string.digits) for _ in range(8)) + resource = Template(resource).safe_substitute( + {'hostname': socket.gethostname(), + 'rand': rand}) + app.config.set_per('accounts', account, 'resource', resource) return resource
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/cc13f14a646eb07a2b9601a39562461ba...