summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2020-09-18 07:56:20 -0400
committerGitHub <noreply@github.com>2020-09-18 07:56:20 -0400
commit9db4c1b1758c0d6092161c67f9e3a3cf4ff05bdb (patch)
treec921b0001201aa05c3f2b6832d9f7261ba998bb2
parentFix ratelimiting for federation `/send` requests. (#8342) (diff)
downloadsynapse-9db4c1b1758c0d6092161c67f9e3a3cf4ff05bdb.tar.xz
Add flags to /versions about whether new rooms are encrypted by default. (#8343)
Diffstat (limited to '')
-rw-r--r--changelog.d/8343.feature1
-rw-r--r--synapse/rest/client/versions.py19
2 files changed, 20 insertions, 0 deletions
diff --git a/changelog.d/8343.feature b/changelog.d/8343.feature
new file mode 100644
index 0000000000..ccecb22f37
--- /dev/null
+++ b/changelog.d/8343.feature
@@ -0,0 +1 @@
+Add flags to the `/versions` endpoint that includes whether new rooms default to using E2EE.
diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py
index 24ac57f35d..c560edbc59 100644
--- a/synapse/rest/client/versions.py
+++ b/synapse/rest/client/versions.py
@@ -19,6 +19,7 @@
 import logging
 import re
 
+from synapse.api.constants import RoomCreationPreset
 from synapse.http.servlet import RestServlet
 
 logger = logging.getLogger(__name__)
@@ -31,6 +32,20 @@ class VersionsRestServlet(RestServlet):
         super(VersionsRestServlet, self).__init__()
         self.config = hs.config
 
+        # Calculate these once since they shouldn't change after start-up.
+        self.e2ee_forced_public = (
+            RoomCreationPreset.PUBLIC_CHAT
+            in self.config.encryption_enabled_by_default_for_room_presets
+        )
+        self.e2ee_forced_private = (
+            RoomCreationPreset.PRIVATE_CHAT
+            in self.config.encryption_enabled_by_default_for_room_presets
+        )
+        self.e2ee_forced_trusted_private = (
+            RoomCreationPreset.TRUSTED_PRIVATE_CHAT
+            in self.config.encryption_enabled_by_default_for_room_presets
+        )
+
     def on_GET(self, request):
         return (
             200,
@@ -62,6 +77,10 @@ class VersionsRestServlet(RestServlet):
                     "org.matrix.msc2432": True,
                     # Implements additional endpoints as described in MSC2666
                     "uk.half-shot.msc2666": True,
+                    # Whether new rooms will be set to encrypted or not (based on presets).
+                    "io.element.e2ee_forced.public": self.e2ee_forced_public,
+                    "io.element.e2ee_forced.private": self.e2ee_forced_private,
+                    "io.element.e2ee_forced.trusted_private": self.e2ee_forced_trusted_private,
                 },
             },
         )