diff --git a/changelog.d/15929.feature b/changelog.d/15929.feature index f0814ec15dd9..c3aaeae66ee7 100644 --- a/changelog.d/15929.feature +++ b/changelog.d/15929.feature @@ -1,3 +1 @@ -Implement [MSC3814](https://github.com/matrix-org/matrix-spec-proposals/pull/3814), -dehydrated devices v2/shrivelled sessions and move [MSC2697](https://github.com/matrix-org/matrix-spec-proposals/pull/2697) -behind a config flag. Contributed by Nico from Famedly and H-Shay. +Implement [MSC3814](https://github.com/matrix-org/matrix-spec-proposals/pull/3814), dehydrated devices v2/shrivelled sessions and move [MSC2697](https://github.com/matrix-org/matrix-spec-proposals/pull/2697) behind a config flag. Contributed by Nico from Famedly and H-Shay. diff --git a/synapse/config/experimental.py b/synapse/config/experimental.py index e8cd1e68c8c1..1695ed8ca336 100644 --- a/synapse/config/experimental.py +++ b/synapse/config/experimental.py @@ -259,6 +259,15 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None: # once. self.msc3814_enabled: bool = experimental.get("msc3814_enabled", False) + if self.msc2697_enabled and self.msc3814_enabled: + raise ConfigError( + "MSC2697 and MSC3814 should not both be enabled.", + ( + "experimental_features", + "msc3814_enabled", + ), + ) + # MSC3244 (room version capabilities) self.msc3244_enabled: bool = experimental.get("msc3244_enabled", True) diff --git a/synapse/handlers/devicemessage.py b/synapse/handlers/devicemessage.py index 621f4c4449c1..a541d9703cc2 100644 --- a/synapse/handlers/devicemessage.py +++ b/synapse/handlers/devicemessage.py @@ -331,7 +331,15 @@ async def get_events_for_dehydrated_device( # only allow fetching messages for the dehydrated device id currently associated # with the user dehydrated_device = await self.device_handler.get_dehydrated_device(user_id) - if dehydrated_device is None or device_id != dehydrated_device[0]: + if dehydrated_device is None: + raise SynapseError( + HTTPStatus.FORBIDDEN, + "You may only fetch messages for your dehydrated device", + Codes.FORBIDDEN, + ) + + dehydrated_device_id = dehydrated_device[0] + if device_id != dehydrated_device_id: raise SynapseError( HTTPStatus.FORBIDDEN, "You may only fetch messages for your dehydrated device", diff --git a/synapse/rest/client/devices.py b/synapse/rest/client/devices.py index 3223764464a4..89776f639263 100644 --- a/synapse/rest/client/devices.py +++ b/synapse/rest/client/devices.py @@ -231,7 +231,7 @@ class Config: class DehydratedDeviceServlet(RestServlet): """Retrieve or store a dehydrated device. - Implements both MSC2697 and MSC3814. + Implements either MSC2697 and MSC3814. GET /org.matrix.msc2697.v2/dehydrated_device