summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2016-08-30 17:16:00 +0100
committerKegan Dougal <kegan@matrix.org>2016-08-30 17:16:00 +0100
commit572acde4832869c8f7f4daf555296bd1164364d0 (patch)
tree86f13817a8e68fe6e5fc9d7915314523734f3a5c /synapse/config
parentFlake8 (diff)
downloadsynapse-572acde4832869c8f7f4daf555296bd1164364d0.tar.xz
Use None instead of the empty string
Change how we validate the 'url' field as a result.
Diffstat (limited to '')
-rw-r--r--synapse/config/appservice.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/synapse/config/appservice.py b/synapse/config/appservice.py
index 5569c43b35..759209a85b 100644
--- a/synapse/config/appservice.py
+++ b/synapse/config/appservice.py
@@ -86,7 +86,7 @@ def load_appservices(hostname, config_files):
 
 def _load_appservice(hostname, as_info, config_filename):
     required_string_fields = [
-        "id", "url", "as_token", "hs_token", "sender_localpart"
+        "id", "as_token", "hs_token", "sender_localpart"
     ]
     for field in required_string_fields:
         if not isinstance(as_info.get(field), basestring):
@@ -94,6 +94,13 @@ def _load_appservice(hostname, as_info, config_filename):
                 field, config_filename,
             ))
 
+    # 'url' must either be a string or explicitly null, not missing
+    # to avoid accidentally turning off push for ASes.
+    if not isinstance(as_info.get("url"), basestring) and as_info.get("url", "") is not None:
+        raise KeyError(
+            "Required string field or explicit null: 'url' (%s)" % (config_filename,)
+        )
+
     localpart = as_info["sender_localpart"]
     if urllib.quote(localpart) != localpart:
         raise ValueError(
@@ -133,10 +140,10 @@ def _load_appservice(hostname, as_info, config_filename):
             if not isinstance(p, str):
                 raise KeyError("Bad value for 'protocols' item")
 
-    if as_info["url"] == "":
+    if as_info["url"] == None:
         logger.info(
-            "(%s) Explicitly empty 'url' provided. This application service " +
-            "will not receive events or queries.",
+            "(%s) Explicitly empty 'url' provided. This application service"
+            " will not receive events or queries.",
             config_filename,
         )
     return ApplicationService(