mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-09 11:02:11 -04:00
Add types to StreamToken and RoomStreamToken (#8279)
The intention here is to change `StreamToken.room_key` to be a `RoomStreamToken` in a future PR, but that is a big enough change without this refactoring too.
This commit is contained in:
parent
094896a69d
commit
63c0e9e195
5 changed files with 95 additions and 91 deletions
|
@ -481,7 +481,7 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
}
|
||||
|
||||
async def get_users_whose_devices_changed(
|
||||
self, from_key: str, user_ids: Iterable[str]
|
||||
self, from_key: int, user_ids: Iterable[str]
|
||||
) -> Set[str]:
|
||||
"""Get set of users whose devices have changed since `from_key` that
|
||||
are in the given list of user_ids.
|
||||
|
@ -493,7 +493,6 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
Returns:
|
||||
The set of user_ids whose devices have changed since `from_key`
|
||||
"""
|
||||
from_key = int(from_key)
|
||||
|
||||
# Get set of users who *may* have changed. Users not in the returned
|
||||
# list have definitely not changed.
|
||||
|
@ -527,7 +526,7 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
)
|
||||
|
||||
async def get_users_whose_signatures_changed(
|
||||
self, user_id: str, from_key: str
|
||||
self, user_id: str, from_key: int
|
||||
) -> Set[str]:
|
||||
"""Get the users who have new cross-signing signatures made by `user_id` since
|
||||
`from_key`.
|
||||
|
@ -539,7 +538,7 @@ class DeviceWorkerStore(SQLBaseStore):
|
|||
Returns:
|
||||
A set of user IDs with updated signatures.
|
||||
"""
|
||||
from_key = int(from_key)
|
||||
|
||||
if self._user_signature_stream_cache.has_entity_changed(user_id, from_key):
|
||||
sql = """
|
||||
SELECT DISTINCT user_ids FROM user_signature_stream
|
||||
|
|
|
@ -79,8 +79,8 @@ _EventDictReturn = namedtuple(
|
|||
def generate_pagination_where_clause(
|
||||
direction: str,
|
||||
column_names: Tuple[str, str],
|
||||
from_token: Optional[Tuple[int, int]],
|
||||
to_token: Optional[Tuple[int, int]],
|
||||
from_token: Optional[Tuple[Optional[int], int]],
|
||||
to_token: Optional[Tuple[Optional[int], int]],
|
||||
engine: BaseDatabaseEngine,
|
||||
) -> str:
|
||||
"""Creates an SQL expression to bound the columns by the pagination
|
||||
|
@ -535,13 +535,13 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
if limit == 0:
|
||||
return [], end_token
|
||||
|
||||
end_token = RoomStreamToken.parse(end_token)
|
||||
parsed_end_token = RoomStreamToken.parse(end_token)
|
||||
|
||||
rows, token = await self.db_pool.runInteraction(
|
||||
"get_recent_event_ids_for_room",
|
||||
self._paginate_room_events_txn,
|
||||
room_id,
|
||||
from_token=end_token,
|
||||
from_token=parsed_end_token,
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
|
@ -989,8 +989,8 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
bounds = generate_pagination_where_clause(
|
||||
direction=direction,
|
||||
column_names=("topological_ordering", "stream_ordering"),
|
||||
from_token=from_token,
|
||||
to_token=to_token,
|
||||
from_token=from_token.as_tuple(),
|
||||
to_token=to_token.as_tuple() if to_token else None,
|
||||
engine=self.database_engine,
|
||||
)
|
||||
|
||||
|
@ -1083,16 +1083,17 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
and `to_key`).
|
||||
"""
|
||||
|
||||
from_key = RoomStreamToken.parse(from_key)
|
||||
parsed_from_key = RoomStreamToken.parse(from_key)
|
||||
parsed_to_key = None
|
||||
if to_key:
|
||||
to_key = RoomStreamToken.parse(to_key)
|
||||
parsed_to_key = RoomStreamToken.parse(to_key)
|
||||
|
||||
rows, token = await self.db_pool.runInteraction(
|
||||
"paginate_room_events",
|
||||
self._paginate_room_events_txn,
|
||||
room_id,
|
||||
from_key,
|
||||
to_key,
|
||||
parsed_from_key,
|
||||
parsed_to_key,
|
||||
direction,
|
||||
limit,
|
||||
event_filter,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue