diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-02-01 16:35:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-01 21:35:24 +0000 |
commit | 1182ae50635db94d3c9c47990a0befcbf6306b62 (patch) | |
tree | 56bdbf809b884428af3f6fe28e18dc44472077ac /synapse/federation/transport/server | |
parent | Attempt to delete more duplicate rows in receipts_linearized table. (#14915) (diff) | |
download | synapse-1182ae50635db94d3c9c47990a0befcbf6306b62.tar.xz |
Add helper to parse an enum from query args & use it. (#14956)
The `parse_enum` helper pulls an enum value from the query string (by delegating down to the parse_string helper with values generated from the enum). This is used to pull out "f" and "b" in most places and then we thread the resulting Direction enum throughout more code.
Diffstat (limited to 'synapse/federation/transport/server')
-rw-r--r-- | synapse/federation/transport/server/federation.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/federation/transport/server/federation.py b/synapse/federation/transport/server/federation.py index 17c427387e..f7ca87adc4 100644 --- a/synapse/federation/transport/server/federation.py +++ b/synapse/federation/transport/server/federation.py @@ -26,7 +26,7 @@ from typing import ( from typing_extensions import Literal -from synapse.api.constants import EduTypes +from synapse.api.constants import Direction, EduTypes from synapse.api.errors import Codes, SynapseError from synapse.api.room_versions import RoomVersions from synapse.api.urls import FEDERATION_UNSTABLE_PREFIX, FEDERATION_V2_PREFIX @@ -234,9 +234,10 @@ class FederationTimestampLookupServlet(BaseFederationServerServlet): room_id: str, ) -> Tuple[int, JsonDict]: timestamp = parse_integer_from_args(query, "ts", required=True) - direction = parse_string_from_args( - query, "dir", default="f", allowed_values=["f", "b"], required=True + direction_str = parse_string_from_args( + query, "dir", allowed_values=["f", "b"], required=True ) + direction = Direction(direction_str) return await self.handler.on_timestamp_to_event_request( origin, room_id, timestamp, direction |