From 2c7c12bc6e13ea36ea56ede8292f5baa1eb12643 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Thu, 28 Aug 2014 17:39:34 +0100 Subject: Initial room event stream token must be s0, not s1, or everyone will miss the very first room event --- synapse/storage/stream.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'synapse/storage') diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 4f42afc015..4945b0796e 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -294,7 +294,7 @@ class StreamStore(SQLBaseStore): logger.debug("get_room_events_max_id: %s", res) if not res or not res[0] or not res[0]["m"]: - return "s1" + return "s0" key = res[0]["m"] return "s%d" % (key,) -- cgit 1.4.1 From ee06023573811a06853d28b613cc823282aa3490 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 29 Aug 2014 13:28:02 +0100 Subject: Get the equalities right. --- synapse/handlers/message.py | 7 +++++-- synapse/storage/stream.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'synapse/storage') diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index 32548e66fb..3d7f97bcff 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -277,10 +277,13 @@ class MessageHandler(BaseRoomHandler): end_token=now_token.events_key, ) + start_token = now_token.copy_and_replace("events_key", token[0]) + end_token = now_token.copy_and_replace("events_key", token[1]) + d["messages"] = { "chunk": [m.get_dict() for m in messages], - "start": token[0], - "end": token[1], + "start": start_token.to_string(), + "end": end_token.to_string(), } current_state = yield self.store.get_current_state( diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 4945b0796e..0b78222827 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -205,8 +205,11 @@ class StreamStore(SQLBaseStore): with_feedback=False): # TODO (erikj): Handle compressed feedback - from_comp = '<' if direction =='b' else '>' - to_comp = '>' if direction =='b' else '<' + # Tokens really represent positions between elements, but we use + # the convention of pointing to the event before the gap. Hence + # we have a bit of asymmetry when it comes to equalities. + from_comp = '<=' if direction =='b' else '>' + to_comp = '>' if direction =='b' else '<=' order = "DESC" if direction == 'b' else "ASC" args = [room_id] -- cgit 1.4.1