mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-05 02:34:13 -04:00
Use an enum for direction. (#14927)
For better type safety we use an enum instead of strings to configure direction (backwards or forwards).
This commit is contained in:
parent
fc35e0673f
commit
265735db9d
9 changed files with 76 additions and 44 deletions
|
@ -30,7 +30,7 @@ from typing import (
|
|||
|
||||
import attr
|
||||
|
||||
from synapse.api.constants import MAIN_TIMELINE, RelationTypes
|
||||
from synapse.api.constants import MAIN_TIMELINE, Direction, RelationTypes
|
||||
from synapse.api.errors import SynapseError
|
||||
from synapse.events import EventBase
|
||||
from synapse.storage._base import SQLBaseStore
|
||||
|
@ -168,7 +168,7 @@ class RelationsWorkerStore(SQLBaseStore):
|
|||
relation_type: Optional[str] = None,
|
||||
event_type: Optional[str] = None,
|
||||
limit: int = 5,
|
||||
direction: str = "b",
|
||||
direction: Direction = Direction.BACKWARDS,
|
||||
from_token: Optional[StreamToken] = None,
|
||||
to_token: Optional[StreamToken] = None,
|
||||
) -> Tuple[List[_RelatedEvent], Optional[StreamToken]]:
|
||||
|
@ -181,8 +181,8 @@ class RelationsWorkerStore(SQLBaseStore):
|
|||
relation_type: Only fetch events with this relation type, if given.
|
||||
event_type: Only fetch events with this event type, if given.
|
||||
limit: Only fetch the most recent `limit` events.
|
||||
direction: Whether to fetch the most recent first (`"b"`) or the
|
||||
oldest first (`"f"`).
|
||||
direction: Whether to fetch the most recent first (backwards) or the
|
||||
oldest first (forwards).
|
||||
from_token: Fetch rows from the given token, or from the start if None.
|
||||
to_token: Fetch rows up to the given token, or up to the end if None.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue