summary refs log tree commit diff
path: root/synapse/storage/databases
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-08-18 18:20:01 +0100
committerRichard van der Hoff <richard@matrix.org>2020-08-18 18:20:01 +0100
commitb4c1cfacc2c13b29b5b490389d09680de6954e94 (patch)
treec060434aa4f48bf7a90481c97399f42da1565c09 /synapse/storage/databases
parentMerge branch 'develop' into matrix-org-hotfixes (diff)
parentAdd a link to the matrix-synapse-rest-password-provider. (#8111) (diff)
downloadsynapse-b4c1cfacc2c13b29b5b490389d09680de6954e94.tar.xz
Merge branch 'develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r--synapse/storage/databases/main/stream.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/synapse/storage/databases/main/stream.py b/synapse/storage/databases/main/stream.py

index 8ccfb8fc46..4377bddb8c 100644 --- a/synapse/storage/databases/main/stream.py +++ b/synapse/storage/databases/main/stream.py
@@ -582,6 +582,19 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): ) return "t%d-%d" % (topo, token) + async def get_stream_id_for_event(self, event_id: str) -> int: + """The stream ID for an event + Args: + event_id: The id of the event to look up a stream token for. + Raises: + StoreError if the event wasn't in the database. + Returns: + A stream ID. + """ + return await self.db_pool.simple_select_one_onecol( + table="events", keyvalues={"event_id": event_id}, retcol="stream_ordering" + ) + async def get_stream_token_for_event(self, event_id: str) -> str: """The stream token for an event Args: @@ -591,10 +604,8 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): Returns: A "s%d" stream token. """ - row = await self.db_pool.simple_select_one_onecol( - table="events", keyvalues={"event_id": event_id}, retcol="stream_ordering" - ) - return "s%d" % (row,) + stream_id = await self.get_stream_id_for_event(event_id) + return "s%d" % (stream_id,) async def get_topological_token_for_event(self, event_id: str) -> str: """The stream token for an event