summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-09-09 13:25:22 +0100
committerMark Haines <mark.haines@matrix.org>2015-09-09 13:25:22 +0100
commit89ae0166ded093be2343409cfe42f475dea83139 (patch)
tree582d239fedd24eae7a451328c8fe1499e9dd654b /synapse/storage
parentInclude rooms that a user has left in an initialSync. Include the state and m... (diff)
downloadsynapse-89ae0166ded093be2343409cfe42f475dea83139.tar.xz
Allow room initialSync for users that have left the room, returning a snapshot of how the room was when they left it
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/stream.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index d7fe423f5a..0abfa86cd2 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -379,6 +379,21 @@ class StreamStore(SQLBaseStore):
             )
             defer.returnValue("t%d-%d" % (topo, token))
 
+    def get_stream_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 "s%d" stream token.
+        """
+        return self._simple_select_one_onecol(
+            table="events",
+            keyvalues={"event_id": event_id},
+            retcol="stream_ordering",
+        ).addCallback(lambda stream_ordering: "s%d" % (stream_ordering,))
+
     def _get_max_topological_txn(self, txn):
         txn.execute(
             "SELECT MAX(topological_ordering) FROM events"