summary refs log tree commit diff
path: root/synapse/handlers/room_member.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-01-22 12:13:46 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2019-01-22 12:13:46 +0000
commitc4875d8c767035036fa1e5c1ee58e9c01ac1e08d (patch)
tree6f18dd73d01387ad19355d1f9fc40a7b3e49ff3e /synapse/handlers/room_member.py
parentFix comments (diff)
downloadsynapse-c4875d8c767035036fa1e5c1ee58e9c01ac1e08d.tar.xz
Prevent duplicate room IDs in m.direct
Diffstat (limited to 'synapse/handlers/room_member.py')
-rw-r--r--synapse/handlers/room_member.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py
index d14da4bc7f..cdaf65cdef 100644
--- a/synapse/handlers/room_member.py
+++ b/synapse/handlers/room_member.py
@@ -248,16 +248,15 @@ class RoomMemberHandler(object):
 
                     # Check which key this room is under
                     for key, room_id_list in direct_rooms.items():
-                        for rid in room_id_list:
-                            if rid == old_room_id:
-                                # Add new room_id to this key
-                                direct_rooms[key].append(room_id)
-
-                                # Save back to user's m.direct account data
-                                yield self.store.add_account_data_for_user(
-                                    user_id, "m.direct", direct_rooms,
-                                )
-                                break
+                        if old_room_id in room_id_list and room_id not in room_id_list:
+                            # Add new room_id to this key
+                            direct_rooms[key].append(room_id)
+
+                            # Save back to user's m.direct account data
+                            yield self.store.add_account_data_for_user(
+                                user_id, "m.direct", direct_rooms,
+                            )
+                            break
 
                 # Copy room tags if applicable
                 if room_tags: