Add flags to /versions about whether new rooms are encrypted by default. (#8343)

This commit is contained in:
Patrick Cloke 2020-09-18 07:56:20 -04:00 committed by GitHub
parent 14b5b48a22
commit 9db4c1b175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

1
changelog.d/8343.feature Normal file
View File

@ -0,0 +1 @@
Add flags to the `/versions` endpoint that includes whether new rooms default to using E2EE.

View File

@ -19,6 +19,7 @@
import logging import logging
import re import re
from synapse.api.constants import RoomCreationPreset
from synapse.http.servlet import RestServlet from synapse.http.servlet import RestServlet
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -31,6 +32,20 @@ class VersionsRestServlet(RestServlet):
super(VersionsRestServlet, self).__init__() super(VersionsRestServlet, self).__init__()
self.config = hs.config 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): def on_GET(self, request):
return ( return (
200, 200,
@ -62,6 +77,10 @@ class VersionsRestServlet(RestServlet):
"org.matrix.msc2432": True, "org.matrix.msc2432": True,
# Implements additional endpoints as described in MSC2666 # Implements additional endpoints as described in MSC2666
"uk.half-shot.msc2666": True, "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,
}, },
}, },
) )