summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2016-04-27 15:09:55 +0100
committerDavid Baker <dave@matrix.org>2016-04-27 15:09:55 +0100
commitfa12209c1b297a1710f487744a8a143d6cb6a2d1 (patch)
treefbaa9f9219946cb349351e5afca62b97e4105d7d /synapse/config
parentMore variable calculation for email notifs (diff)
downloadsynapse-fa12209c1b297a1710f487744a8a143d6cb6a2d1.tar.xz
Hopefully all remaining bits for email notifs
Add public facing base url to the server so synapse knows what URL to use when converting mxc to http urls for use in emails
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/emailconfig.py9
-rw-r--r--synapse/config/server.py8
2 files changed, 16 insertions, 1 deletions
diff --git a/synapse/config/emailconfig.py b/synapse/config/emailconfig.py
index 68fb4d8060..893034e2ef 100644
--- a/synapse/config/emailconfig.py
+++ b/synapse/config/emailconfig.py
@@ -25,17 +25,19 @@ class EmailConfig(Config):
     """
 
     def read_config(self, config):
+        self.email_enable_notifs = False
+
         email_config = config.get("email", None)
         if email_config:
             self.email_enable_notifs = email_config.get("enable_notifs", True)
 
+        if self.email_enable_notifs:
             required = [
                 "smtp_host",
                 "smtp_port",
                 "notif_from",
                 "template_dir",
                 "notif_template_html",
-
             ]
 
             missing = []
@@ -49,6 +51,11 @@ class EmailConfig(Config):
                     (", ".join(["email."+k for k in missing]),)
                 )
 
+            if config.get("public_baseurl") is None:
+                raise RuntimeError(
+                    "email.enable_notifs is True but no public_baseurl is set"
+                )
+
             self.email_smtp_host = email_config["smtp_host"]
             self.email_smtp_port = email_config["smtp_port"]
             self.email_notif_from = email_config["notif_from"]
diff --git a/synapse/config/server.py b/synapse/config/server.py
index df4707e1d1..19af39da70 100644
--- a/synapse/config/server.py
+++ b/synapse/config/server.py
@@ -28,6 +28,11 @@ class ServerConfig(Config):
         self.print_pidfile = config.get("print_pidfile")
         self.user_agent_suffix = config.get("user_agent_suffix")
         self.use_frozen_dicts = config.get("use_frozen_dicts", True)
+        self.public_baseurl = config.get("public_baseurl")
+
+        if self.public_baseurl is not None:
+            if self.public_baseurl[-1] != '/':
+                self.public_baseurl += '/'
 
         self.listeners = config.get("listeners", [])
 
@@ -142,6 +147,9 @@ class ServerConfig(Config):
         # Whether to serve a web client from the HTTP/HTTPS root resource.
         web_client: True
 
+        # The server's public-facing base URL
+        # https://example.com:8448/
+
         # Set the soft limit on the number of file descriptors synapse can use
         # Zero is used to indicate synapse should set the soft limit to the
         # hard limit.