From 698e44a73237c6db520786c6248df20543aae47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Tue, 1 Sep 2020 13:07:32 +0200 Subject: [PATCH] Fix /upgrade account data problems --- src/database/rooms.rs | 47 ++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/src/database/rooms.rs b/src/database/rooms.rs index eee47f3a..22e61e69 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -804,7 +804,6 @@ impl Rooms { .predecessor { // Copy user settings from predecessor to the current room: - // - Push rules // // TODO: finish this once push rules are implemented. @@ -829,37 +828,27 @@ impl Rooms { // ) // .ok(); - // - Tags - if let Some(basic_event) = account_data.get::( + // Copy old tags to new room + if let Some(tag_event) = account_data.get::( Some(&predecessor.room_id), user_id, EventType::Tag, )? { - let tag_event_content = basic_event.content; - account_data - .update( - Some(room_id), - user_id, - EventType::Tag, - &tag_event_content, - globals, - ) + .update(Some(room_id), user_id, EventType::Tag, &tag_event, globals) .ok(); }; - // - Direct chat - if let Some(basic_event) = account_data + // Copy direct chat flag + if let Some(mut direct_event) = account_data .get::( - None, - user_id, - EventType::Direct, - )? - { - let mut direct_event_content = basic_event.content; + None, + user_id, + EventType::Direct, + )? { let mut room_ids_updated = false; - for room_ids in direct_event_content.0.values_mut() { + for room_ids in direct_event.content.0.values_mut() { if room_ids.iter().any(|r| r == &predecessor.room_id) { room_ids.push(room_id.clone()); room_ids_updated = true; @@ -867,15 +856,13 @@ impl Rooms { } if room_ids_updated { - account_data - .update( - None, - user_id, - EventType::Direct, - &direct_event_content, - globals, - ) - .ok(); + account_data.update( + None, + user_id, + EventType::Direct, + &direct_event, + globals, + )?; } }; }