mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-09 21:52:17 -04:00
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.
This commit is contained in:
parent
230a831c73
commit
1182ae5063
25 changed files with 176 additions and 96 deletions
|
@ -34,7 +34,13 @@ from prometheus_client import Counter, Gauge, Histogram
|
|||
from twisted.internet.abstract import isIPAddress
|
||||
from twisted.python import failure
|
||||
|
||||
from synapse.api.constants import EduTypes, EventContentFields, EventTypes, Membership
|
||||
from synapse.api.constants import (
|
||||
Direction,
|
||||
EduTypes,
|
||||
EventContentFields,
|
||||
EventTypes,
|
||||
Membership,
|
||||
)
|
||||
from synapse.api.errors import (
|
||||
AuthError,
|
||||
Codes,
|
||||
|
@ -218,7 +224,7 @@ class FederationServer(FederationBase):
|
|||
return 200, res
|
||||
|
||||
async def on_timestamp_to_event_request(
|
||||
self, origin: str, room_id: str, timestamp: int, direction: str
|
||||
self, origin: str, room_id: str, timestamp: int, direction: Direction
|
||||
) -> Tuple[int, Dict[str, Any]]:
|
||||
"""When we receive a federated `/timestamp_to_event` request,
|
||||
handle all of the logic for validating and fetching the event.
|
||||
|
@ -228,7 +234,7 @@ class FederationServer(FederationBase):
|
|||
room_id: Room to fetch the event from
|
||||
timestamp: The point in time (inclusive) we should navigate from in
|
||||
the given direction to find the closest event.
|
||||
direction: ["f"|"b"] to indicate whether we should navigate forward
|
||||
direction: indicates whether we should navigate forward
|
||||
or backward from the given timestamp to find the closest event.
|
||||
|
||||
Returns:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue