summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/appservice/api.py10
-rw-r--r--synapse/config/appservice.py15
2 files changed, 16 insertions, 9 deletions
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py
index ee63f06359..cc4af23962 100644
--- a/synapse/appservice/api.py
+++ b/synapse/appservice/api.py
@@ -67,7 +67,7 @@ class ApplicationServiceApi(SimpleHttpClient):
 
     @defer.inlineCallbacks
     def query_user(self, service, user_id):
-        if service.url == "":
+        if service.url is None:
             defer.returnValue(False)
         uri = service.url + ("/users/%s" % urllib.quote(user_id))
         response = None
@@ -88,7 +88,7 @@ class ApplicationServiceApi(SimpleHttpClient):
 
     @defer.inlineCallbacks
     def query_alias(self, service, alias):
-        if service.url == "":
+        if service.url is None:
             defer.returnValue(False)
         uri = service.url + ("/rooms/%s" % urllib.quote(alias))
         response = None
@@ -117,7 +117,7 @@ class ApplicationServiceApi(SimpleHttpClient):
             raise ValueError(
                 "Unrecognised 'kind' argument %r to query_3pe()", kind
             )
-        if service.url == "":
+        if service.url is None:
             defer.returnValue([])
 
         uri = "%s%s/thirdparty/%s/%s" % (
@@ -151,7 +151,7 @@ class ApplicationServiceApi(SimpleHttpClient):
             defer.returnValue([])
 
     def get_3pe_protocol(self, service, protocol):
-        if service.url == "":
+        if service.url is None:
             defer.returnValue({})
 
         @defer.inlineCallbacks
@@ -175,7 +175,7 @@ class ApplicationServiceApi(SimpleHttpClient):
 
     @defer.inlineCallbacks
     def push_bulk(self, service, events, txn_id=None):
-        if service.url == "":
+        if service.url is None:
             defer.returnValue(True)
 
         events = self._serialize(events)
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(