diff options
author | Eric Eastwood <erice@element.io> | 2022-04-06 05:40:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 11:40:28 +0100 |
commit | 793d03e2c5c8e688380b8070d53a7e500b7734af (patch) | |
tree | d417032e5e8df81946bd1a9a453965e5ffa66d5e /synapse/storage | |
parent | Add missing dependency on importlib_metadata (#12384) (diff) | |
download | synapse-793d03e2c5c8e688380b8070d53a7e500b7734af.tar.xz |
Generate historic pagination token for `/messages` when no `?from` token provided (#12370)
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/stream.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/synapse/storage/databases/main/stream.py b/synapse/storage/databases/main/stream.py index 8e764790db..82e9ef02d2 100644 --- a/synapse/storage/databases/main/stream.py +++ b/synapse/storage/databases/main/stream.py @@ -748,21 +748,23 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): "get_room_event_before_stream_ordering", _f ) - async def get_room_events_max_id(self, room_id: Optional[str] = None) -> str: - """Returns the current token for rooms stream. - - By default, it returns the current global stream token. Specifying a - `room_id` causes it to return the current room specific topological - token. + async def get_current_room_stream_token_for_room_id( + self, room_id: Optional[str] = None + ) -> RoomStreamToken: + """Returns the current position of the rooms stream. + + By default, it returns a live token with the current global stream + token. Specifying a `room_id` causes it to return a historic token with + the room specific topological token. """ - token = self.get_room_max_stream_ordering() + stream_ordering = self.get_room_max_stream_ordering() if room_id is None: - return "s%d" % (token,) + return RoomStreamToken(None, stream_ordering) else: topo = await self.db_pool.runInteraction( "_get_max_topological_txn", self._get_max_topological_txn, room_id ) - return "t%d-%d" % (topo, token) + return RoomStreamToken(topo, stream_ordering) def get_stream_id_for_event_txn( self, |