summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--synapse/handlers/room.py2
-rw-r--r--synapse/storage/stream.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index aca795e1c4..a71cba8ef1 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -1022,7 +1022,7 @@ class RoomEventSource(object):
             events = list(room_events)
             events.extend(e for evs, _ in room_to_events.values() for e in evs)
 
-            events.sort(key=lambda e: e.internal_metadata.after)
+            events.sort(key=lambda e: e.internal_metadata.order)
 
             if limit:
                 events[:] = events[:limit]
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index fd84aa8996..a03458c2fc 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -598,6 +598,10 @@ class StreamStore(SQLBaseStore):
             internal = event.internal_metadata
             internal.before = str(RoomStreamToken(topo, stream - 1))
             internal.after = str(RoomStreamToken(topo, stream))
+            internal.order = (
+                int(topo) if topo else 0,
+                int(stream),
+            )
 
     @defer.inlineCallbacks
     def get_events_around(self, room_id, event_id, before_limit, after_limit):