diff options
author | Kegsay <kegsay@gmail.com> | 2016-08-30 17:56:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-30 17:56:05 +0100 |
commit | 998666be6404865d50bf3a2dc5aa322b1a12f198 (patch) | |
tree | 58b6eb93014cf90dbb30c781aa804ee048e5f72e /synapse/config/appservice.py | |
parent | Merge pull request #1055 from matrix-org/erikj/occaisonally_persist (diff) | |
parent | flake8 (diff) | |
download | synapse-998666be6404865d50bf3a2dc5aa322b1a12f198.tar.xz |
Merge pull request #1056 from matrix-org/kegan/appservice-url-is-optional
Allow application services to have an optional 'url'
Diffstat (limited to 'synapse/config/appservice.py')
-rw-r--r-- | synapse/config/appservice.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/synapse/config/appservice.py b/synapse/config/appservice.py index dfe43b0b4c..d7537e8d44 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,14 @@ 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( @@ -132,6 +140,13 @@ def _load_appservice(hostname, as_info, config_filename): for p in protocols: if not isinstance(p, str): raise KeyError("Bad value for 'protocols' item") + + if as_info["url"] is None: + logger.info( + "(%s) Explicitly empty 'url' provided. This application service" + " will not receive events or queries.", + config_filename, + ) return ApplicationService( token=as_info["as_token"], url=as_info["url"], |