aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Weth <git@jonathanweth.de>2021-07-01 14:42:40 +0200
committerJonathan Weth <git@jonathanweth.de>2021-07-01 14:42:40 +0200
commit7fdbc1ca20c5df556dd50573ddad46ba405623b6 (patch)
tree3dd6e280e12b6fd34c24968e70af66e5e9f71f94
parentf2b1dc8e53f5dbe353a9c35c37550d00ba206bdb (diff)
downloadRWA.Support.SessionService-7fdbc1ca20c5df556dd50573ddad46ba405623b6.tar.gz
RWA.Support.SessionService-7fdbc1ca20c5df556dd50573ddad46ba405623b6.tar.bz2
RWA.Support.SessionService-7fdbc1ca20c5df556dd50573ddad46ba405623b6.zip
Check if the host is already present
-rwxr-xr-xrwa/support/sessionservice/service.py9
1 files changed, 8 insertions, 1 deletions
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)