diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-07-01 21:49:24 +0200 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2021-07-01 21:49:24 +0200 |
commit | 2a354a70597dbbe23b203aa7f2693a9388b086d1 (patch) | |
tree | 25e338c9733dd3bedb1da62a7f6f0a1a0d980cd2 /rwa | |
parent | 94cb2b582e2ae774d7e61237ea9c6ecde212a872 (diff) | |
download | RWA.Support.SessionService-2a354a70597dbbe23b203aa7f2693a9388b086d1.tar.gz RWA.Support.SessionService-2a354a70597dbbe23b203aa7f2693a9388b086d1.tar.bz2 RWA.Support.SessionService-2a354a70597dbbe23b203aa7f2693a9388b086d1.zip |
Fix duplicate url matching
Diffstat (limited to 'rwa')
-rwxr-xr-x | rwa/support/sessionservice/service.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py index 7bb45b2..95c014b 100755 --- a/rwa/support/sessionservice/service.py +++ b/rwa/support/sessionservice/service.py @@ -96,7 +96,7 @@ class RWASupportSessionService(dbus.service.Object): :return: Whether the string is an URL. """ valid = validators.url(url) - logging.debug(f"Is {url} an URL: {valid}") + logging.debug(f"Is '{url}' an URL: {valid}") return valid def _get_web_app_hosts(self) -> str: @@ -224,13 +224,20 @@ class RWASupportSessionService(dbus.service.Object): logging.info('The response to D-Bus caller: "%s"', response) return response - if host_url 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_url) - - response = json.dumps({"status": "error", "type": "duplicate"}) - logging.info('The response to D-Bus caller: "%s"', response) - return response + try: + for uuid, host in self.settings.web_app_hosts.items(): + if host_url in host['url']: + logging.warning("Given URL is already present!") + logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url) + + response = json.dumps({"status": "error", "type": "duplicate"}) + logging.info('The response to D-Bus caller: "%s"', response) + return response + except (KeyError, IndexError): + logging.warning( + 'Got an exception while trying to find given url ' + 'in already existing hosts!' + ) res = self._do_api_handshake(host_url) if res["status"] == "error": |