summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-07-02 11:40:22 +0100
committerErik Johnston <erik@matrix.org>2015-07-02 11:45:44 +0100
commitddf7979531cf514ee54e280714bdf228d88a62d5 (patch)
tree5bf9fe3122e56e3a336b83995a52c4662dfd059c /synapse
parentAdd basic ReceiptHandler (diff)
downloadsynapse-ddf7979531cf514ee54e280714bdf228d88a62d5.tar.xz
Add receipts_key to StreamToken
Diffstat (limited to 'synapse')
-rw-r--r--synapse/notifier.py2
-rw-r--r--synapse/streams/events.py3
-rw-r--r--synapse/types.py6
3 files changed, 8 insertions, 3 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index bdd03dcbe8..f13164dbdc 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -283,7 +283,7 @@ class Notifier(object):
 
     @defer.inlineCallbacks
     def wait_for_events(self, user, rooms, timeout, callback,
-                        from_token=StreamToken("s0", "0", "0")):
+                        from_token=StreamToken("s0", "0", "0", "0")):
         """Wait until the callback returns a non empty response or the
         timeout fires.
         """
diff --git a/synapse/streams/events.py b/synapse/streams/events.py
index dff7970bea..0a1a3a3d03 100644
--- a/synapse/streams/events.py
+++ b/synapse/streams/events.py
@@ -62,7 +62,8 @@ class EventSources(object):
             ),
             typing_key=(
                 yield self.sources["typing"].get_current_key()
-            )
+            ),
+            receipt_key="0",
         )
         defer.returnValue(token)
 
diff --git a/synapse/types.py b/synapse/types.py
index 1b21160c57..dd1b10d646 100644
--- a/synapse/types.py
+++ b/synapse/types.py
@@ -100,7 +100,7 @@ class EventID(DomainSpecificString):
 class StreamToken(
     namedtuple(
         "Token",
-        ("room_key", "presence_key", "typing_key")
+        ("room_key", "presence_key", "typing_key", "receipt_key")
     )
 ):
     _SEPARATOR = "_"
@@ -109,6 +109,9 @@ class StreamToken(
     def from_string(cls, string):
         try:
             keys = string.split(cls._SEPARATOR)
+            if len(keys) == len(cls._fields) - 1:
+                # i.e. old token from before receipt_key
+                keys.append("0")
             return cls(*keys)
         except:
             raise SynapseError(400, "Invalid Token")
@@ -131,6 +134,7 @@ class StreamToken(
             (other_token.room_stream_id < self.room_stream_id)
             or (int(other_token.presence_key) < int(self.presence_key))
             or (int(other_token.typing_key) < int(self.typing_key))
+            or (int(other_token.receipt_key) < int(self.receipt_key))
         )
 
     def copy_and_advance(self, key, new_value):