|
|
|
@ -804,7 +804,6 @@ impl Rooms { |
|
|
|
.predecessor |
|
|
|
.predecessor |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Copy user settings from predecessor to the current room:
|
|
|
|
// Copy user settings from predecessor to the current room:
|
|
|
|
|
|
|
|
|
|
|
|
// - Push rules
|
|
|
|
// - Push rules
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// TODO: finish this once push rules are implemented.
|
|
|
|
// TODO: finish this once push rules are implemented.
|
|
|
|
@ -829,37 +828,27 @@ impl Rooms { |
|
|
|
// )
|
|
|
|
// )
|
|
|
|
// .ok();
|
|
|
|
// .ok();
|
|
|
|
|
|
|
|
|
|
|
|
// - Tags
|
|
|
|
// Copy old tags to new room
|
|
|
|
if let Some(basic_event) = account_data.get::<ruma::events::tag::TagEvent>( |
|
|
|
if let Some(tag_event) = account_data.get::<ruma::events::tag::TagEvent>( |
|
|
|
Some(&predecessor.room_id), |
|
|
|
Some(&predecessor.room_id), |
|
|
|
user_id, |
|
|
|
user_id, |
|
|
|
EventType::Tag, |
|
|
|
EventType::Tag, |
|
|
|
)? { |
|
|
|
)? { |
|
|
|
let tag_event_content = basic_event.content; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
account_data |
|
|
|
account_data |
|
|
|
.update( |
|
|
|
.update(Some(room_id), user_id, EventType::Tag, &tag_event, globals) |
|
|
|
Some(room_id), |
|
|
|
|
|
|
|
user_id, |
|
|
|
|
|
|
|
EventType::Tag, |
|
|
|
|
|
|
|
&tag_event_content, |
|
|
|
|
|
|
|
globals, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.ok(); |
|
|
|
.ok(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// - Direct chat
|
|
|
|
// Copy direct chat flag
|
|
|
|
if let Some(basic_event) = account_data |
|
|
|
if let Some(mut direct_event) = account_data |
|
|
|
.get::<ruma::events::direct::DirectEvent>( |
|
|
|
.get::<ruma::events::direct::DirectEvent>( |
|
|
|
None, |
|
|
|
None, |
|
|
|
user_id, |
|
|
|
user_id, |
|
|
|
EventType::Direct, |
|
|
|
EventType::Direct, |
|
|
|
)? |
|
|
|
)? { |
|
|
|
{ |
|
|
|
|
|
|
|
let mut direct_event_content = basic_event.content; |
|
|
|
|
|
|
|
let mut room_ids_updated = false; |
|
|
|
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) { |
|
|
|
if room_ids.iter().any(|r| r == &predecessor.room_id) { |
|
|
|
room_ids.push(room_id.clone()); |
|
|
|
room_ids.push(room_id.clone()); |
|
|
|
room_ids_updated = true; |
|
|
|
room_ids_updated = true; |
|
|
|
@ -867,15 +856,13 @@ impl Rooms { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if room_ids_updated { |
|
|
|
if room_ids_updated { |
|
|
|
account_data |
|
|
|
account_data.update( |
|
|
|
.update( |
|
|
|
|
|
|
|
None, |
|
|
|
None, |
|
|
|
user_id, |
|
|
|
user_id, |
|
|
|
EventType::Direct, |
|
|
|
EventType::Direct, |
|
|
|
&direct_event_content, |
|
|
|
&direct_event, |
|
|
|
globals, |
|
|
|
globals, |
|
|
|
) |
|
|
|
)?; |
|
|
|
.ok(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|