From 7fdbc1ca20c5df556dd50573ddad46ba405623b6 Mon Sep 17 00:00:00 2001 From: Jonathan Weth Date: Thu, 1 Jul 2021 14:42:40 +0200 Subject: Check if the host is already present --- rwa/support/sessionservice/service.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py index bb9a1e1..471d599 100755 --- a/rwa/support/sessionservice/service.py +++ b/rwa/support/sessionservice/service.py @@ -194,8 +194,9 @@ class RWASupportSessionService(dbus.service.Object): * ``permission_denied`` * ``unsupported_server`` * ``invalid_url`` + * ``duplicate`` """ - host = str(host) + host = str(host).rstrip("/") logging.info('D-Bus method call: %s("%s")', "add_web_app_host", host) @@ -204,8 +205,14 @@ class RWASupportSessionService(dbus.service.Object): logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host) return json.dumps({"status": "error", "type": "invalid_url"}) + if host in self.settings.web_app_hosts: + logging.warning("Given URL is already present!") + logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host) + return json.dumps({"status": "error", "type": "duplicate"}) + res = self._do_api_handshake(host) if res["status"] == "error": + logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host) return json.dumps(res) self.settings.web_app_hosts.append(host) -- cgit v1.2.3