0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-15 17:53:51 +01:00

Merge pull request #357 from matrix-org/rav/SYN-516

Don't fiddle with results returned by event sources
This commit is contained in:
Mark Haines 2015-11-09 19:26:46 +00:00
commit 889388f105

View file

@ -311,8 +311,13 @@ class SyncHandler(BaseHandler):
ephemeral_by_room = {} ephemeral_by_room = {}
for event in typing: for event in typing:
room_id = event.pop("room_id") # we want to exclude the room_id from the event, but modifying the
ephemeral_by_room.setdefault(room_id, []).append(event) # 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" 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) now_token = now_token.copy_and_replace("receipt_key", receipt_key)
for event in receipts: for event in receipts:
room_id = event.pop("room_id") room_id = event["room_id"]
ephemeral_by_room.setdefault(room_id, []).append(event) # 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)) defer.returnValue((now_token, ephemeral_by_room))