mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-14 07:42:21 -04:00
Generate historic pagination token for /messages
when no ?from
token provided (#12370)
This commit is contained in:
parent
573cd0f92f
commit
793d03e2c5
6 changed files with 26 additions and 14 deletions
|
@ -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.
|
||||
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 the current global stream token. Specifying a
|
||||
`room_id` causes it to return the current room specific topological
|
||||
token.
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue