diff options
author | Jonathan Weth <mail@jonathanweth.de> | 2021-07-01 12:43:21 +0000 |
---|---|---|
committer | Jonathan Weth <mail@jonathanweth.de> | 2021-07-01 12:43:21 +0000 |
commit | 8c64f8965d1308f4c5fbae7c3c10af65b10e9dac (patch) | |
tree | 3dd6e280e12b6fd34c24968e70af66e5e9f71f94 | |
parent | f2b1dc8e53f5dbe353a9c35c37550d00ba206bdb (diff) | |
parent | 7fdbc1ca20c5df556dd50573ddad46ba405623b6 (diff) | |
download | RWA.Support.SessionService-8c64f8965d1308f4c5fbae7c3c10af65b10e9dac.tar.gz RWA.Support.SessionService-8c64f8965d1308f4c5fbae7c3c10af65b10e9dac.tar.bz2 RWA.Support.SessionService-8c64f8965d1308f4c5fbae7c3c10af65b10e9dac.zip |
Merge branch '16-url-duplication-should-be-checked' into 'master'
Resolve "URL duplication should be checked"
Closes #16
See merge request remotewebapp/rwa.support.sessionservice!13
-rwxr-xr-x | rwa/support/sessionservice/service.py | 9 |
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) |