summary refs log tree commit diff
path: root/synapse/storage/stream.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-10-27 11:02:30 +0100
committerErik Johnston <erik@matrix.org>2016-10-27 11:02:30 +0100
commit45bdacd9a75c7e32b0b8708ae58fb9e661376bfd (patch)
tree0118fd2870598a004d7439f67e21c8651f425643 /synapse/storage/stream.py
parentFixup change log (diff)
parentMerge pull request #1098 from matrix-org/markjh/bearer_token (diff)
downloadsynapse-45bdacd9a75c7e32b0b8708ae58fb9e661376bfd.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into release-v0.18.2
Diffstat (limited to 'synapse/storage/stream.py')
-rw-r--r--synapse/storage/stream.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 07ea969d4d..888b1cb35d 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -521,13 +521,20 @@ class StreamStore(SQLBaseStore):
         )
 
     @defer.inlineCallbacks
-    def get_room_events_max_id(self, direction='f'):
+    def get_room_events_max_id(self, room_id=None):
+        """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.
+        """
         token = yield self._stream_id_gen.get_current_token()
-        if direction != 'b':
+        if room_id is None:
             defer.returnValue("s%d" % (token,))
         else:
             topo = yield self.runInteraction(
-                "_get_max_topological_txn", self._get_max_topological_txn
+                "_get_max_topological_txn", self._get_max_topological_txn,
+                room_id,
             )
             defer.returnValue("t%d-%d" % (topo, token))
 
@@ -579,11 +586,11 @@ class StreamStore(SQLBaseStore):
             lambda r: r[0][0] if r else 0
         )
 
-    def _get_max_topological_txn(self, txn):
+    def _get_max_topological_txn(self, txn, room_id):
         txn.execute(
             "SELECT MAX(topological_ordering) FROM events"
-            " WHERE outlier = ?",
-            (False,)
+            " WHERE room_id = ?",
+            (room_id,)
         )
 
         rows = txn.fetchall()