From 7685521e2bafd6ca50e64c34e3ca0bda313e44aa Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 26 Apr 2023 03:30:05 +0200 Subject: [PATCH] Always use the default configuration values for MQTT listeners if not specified --- platypush/backend/mqtt/__init__.py | 38 +++++++++++++----------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/platypush/backend/mqtt/__init__.py b/platypush/backend/mqtt/__init__.py index f03ecb954d..2619ce7dbe 100644 --- a/platypush/backend/mqtt/__init__.py +++ b/platypush/backend/mqtt/__init__.py @@ -258,29 +258,23 @@ class MqttBackend(Backend): def add_listeners(self, *listeners): for i, listener in enumerate(listeners): host = listener.get('host', self.host) - if host: - port = listener.get('port', self._default_mqtt_port) - username = listener.get('username') - password = listener.get('password') - tls_cafile = self._expandpath(listener.get('tls_cafile')) - tls_certfile = self._expandpath(listener.get('tls_certfile')) - tls_keyfile = self._expandpath(listener.get('tls_keyfile')) - tls_version = MQTTPlugin.get_tls_version(listener.get('tls_version')) - tls_ciphers = listener.get('tls_ciphers') - tls_insecure = listener.get('tls_insecure') - else: - host = self.host - port = self.port - username = self.username - password = self.password - tls_cafile = self.tls_cafile - tls_certfile = self.tls_certfile - tls_keyfile = self.tls_keyfile - tls_version = self.tls_version - tls_ciphers = self.tls_ciphers - tls_insecure = self.tls_insecure - + port = listener.get('port', self.port) + username = listener.get('username', self.username) + password = listener.get('password', self.password) + tls_cafile = self._expandpath(listener.get('tls_cafile', self.tls_cafile)) + tls_certfile = self._expandpath( + listener.get('tls_certfile', self.tls_certfile) + ) + tls_keyfile = self._expandpath( + listener.get('tls_keyfile', self.tls_keyfile) + ) + tls_version = MQTTPlugin.get_tls_version( + listener.get('tls_version', self.tls_version) + ) + tls_ciphers = listener.get('tls_ciphers', self.tls_ciphers) + tls_insecure = listener.get('tls_insecure', self.tls_insecure) topics = listener.get('topics') + if not topics: self.logger.warning( 'No list of topics specified for listener n.%d', i + 1