Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Jul 14, 2023
1 parent 664ad97 commit a52a25a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 1 addition & 3 deletions changelog.d/15929.feature
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions synapse/config/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 9 additions & 1 deletion synapse/handlers/devicemessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/client/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a52a25a

Please sign in to comment.