summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-09-21 14:13:10 +0100
committerMark Haines <mark.haines@matrix.org>2015-09-21 14:13:10 +0100
commit1e101ed4a45bad68f4865229e0c8d617fed67065 (patch)
treeae8f50ba58908241ec00d3535add802d06008db9 /synapse
parentClarify which event is returned by check_user_was_in_room (diff)
downloadsynapse-1e101ed4a45bad68f4865229e0c8d617fed67065.tar.xz
Clamp the "to" token for /rooms/{roomId}/messages to when the user left
the room.

There isn't a way for the client to learn a valid "to" token for a room
that they have left in the C-S API but that doesn't stop a client making
one up.
Diffstat (limited to '')
-rw-r--r--synapse/handlers/message.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 5d18aaacf0..bca592f5d7 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -120,6 +120,10 @@ class MessageHandler(BaseHandler):
             if source_config.direction == "f":
                 if source_config.to_key is None:
                     source_config.to_key = str(leave_token)
+                else:
+                    to_token = RoomStreamToken.parse(source_config.to_key)
+                    if leave_token.topological < to_token.topological:
+                        source_config.to_key = str(leave_token)
 
         yield self.hs.get_handlers().federation_handler.maybe_backfill(
             room_id, room_token.topological