summary refs log tree commit diff
path: root/synapse/storage/stream.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-09-09 17:31:09 +0100
committerMark Haines <mark.haines@matrix.org>2015-09-09 17:31:09 +0100
commit09cb5c7d33c32e2cbf5a5b6f6f0e2780338491d2 (patch)
tree6de9ae27ef6ef0630f84a94513f6b7758dc5391d /synapse/storage/stream.py
parentRemove undocumented and unimplemented 'feedback' parameter from the Client-Se... (diff)
downloadsynapse-09cb5c7d33c32e2cbf5a5b6f6f0e2780338491d2.tar.xz
Allow users that have left a room to get the messages that happend in the room before they left
Diffstat (limited to 'synapse/storage/stream.py')
-rw-r--r--synapse/storage/stream.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 5763c462af..3cab06fdef 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -386,7 +386,24 @@ class StreamStore(SQLBaseStore):
             table="events",
             keyvalues={"event_id": event_id},
             retcol="stream_ordering",
-        ).addCallback(lambda stream_ordering: "s%d" % (stream_ordering,))
+        ).addCallback(lambda row: "s%d" % (row,))
+
+    def get_topological_token_for_event(self, event_id):
+        """The stream token for an event
+        Args:
+            event_id(str): The id of the event to look up a stream token for.
+        Raises:
+            StoreError if the event wasn't in the database.
+        Returns:
+            A deferred "t%d-%d" topological token.
+        """
+        return self._simple_select_one(
+            table="events",
+            keyvalues={"event_id": event_id},
+            retcols=("stream_ordering", "topological_ordering"),
+        ).addCallback(lambda row: "t%d-%d" % (
+            row["topological_ordering"], row["stream_ordering"],)
+        )
 
     def _get_max_topological_txn(self, txn):
         txn.execute(