diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2019-01-17 15:22:03 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2019-01-22 11:00:04 +0000 |
commit | 4ff6d2224543146723e3109681636de73a738f25 (patch) | |
tree | 286d570e4df09d8af5a9c5dced3553c1de296ae2 | |
parent | Fix typo (diff) | |
download | synapse-4ff6d2224543146723e3109681636de73a738f25.tar.xz |
Preserve DM status of a room on upgrade
Signed-off-by: Andrew Morgan <andrew@amorgan.xyz>
-rw-r--r-- | synapse/handlers/room.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 8898602eeb..3bfba6c744 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -260,8 +260,27 @@ class RoomCreationHandler(BaseHandler): } } + # Copy over whether this room is considered a direct message by this + # user or not + user_account_data = yield self.store.get_account_data_for_user( + user_id, + ) + + if user_account_data: + direct_rooms = user_account_data[0]["m.direct"] + # Check if this room was a DM + if old_room_id in direct_rooms[user_id]: + # Add this room ID to the list of direct rooms + direct_rooms[user_id].append(new_room_id) + + # Add this room ID to the list of direct rooms for this user + yield self.store.add_account_data_for_user( + user_id, "m.direct", direct_rooms, + ) + initial_state = dict() + # Replicate relevant room events types_to_copy = ( (EventTypes.JoinRules, ""), (EventTypes.Name, ""), |