summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-11-09 19:26:46 +0000
committerMark Haines <mjark@negativecurvature.net>2015-11-09 19:26:46 +0000
commit889388f1059154db5be60e85a0be4a3376505037 (patch)
tree46a96fbb3ceab05cd5af43373e7b2754327850b6 /synapse/handlers
parentAdd a couple of unit tests for room/<x>/messages (diff)
parentDon't fiddle with results returned by event sources (diff)
downloadsynapse-889388f1059154db5be60e85a0be4a3376505037.tar.xz
Merge pull request #357 from matrix-org/rav/SYN-516
Don't fiddle with results returned by event sources
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/sync.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index ff766e3af5..492c1c17d5 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -311,8 +311,13 @@ class SyncHandler(BaseHandler):
         ephemeral_by_room = {}
 
         for event in typing:
-            room_id = event.pop("room_id")
-            ephemeral_by_room.setdefault(room_id, []).append(event)
+            # we want to exclude the room_id from the event, but modifying the
+            # result returned by the event source is poor form (it might cache
+            # the object)
+            room_id = event["room_id"]
+            event_copy = {k: v for (k, v) in event.iteritems()
+                          if k != "room_id"}
+            ephemeral_by_room.setdefault(room_id, []).append(event_copy)
 
         receipt_key = since_token.receipt_key if since_token else "0"
 
@@ -328,8 +333,11 @@ class SyncHandler(BaseHandler):
         now_token = now_token.copy_and_replace("receipt_key", receipt_key)
 
         for event in receipts:
-            room_id = event.pop("room_id")
-            ephemeral_by_room.setdefault(room_id, []).append(event)
+            room_id = event["room_id"]
+            # exclude room id, as above
+            event_copy = {k: v for (k, v) in event.iteritems()
+                          if k != "room_id"}
+            ephemeral_by_room.setdefault(room_id, []).append(event_copy)
 
         defer.returnValue((now_token, ephemeral_by_room))