11use std:: collections:: HashMap ;
22
33use matrix_sdk:: { EncryptionState , RoomState } ;
4+ use ruma:: events:: room:: tombstone:: RoomTombstoneEventContent ;
45use tracing:: warn;
56
67use crate :: {
@@ -26,7 +27,8 @@ pub struct RoomInfo {
2627 is_direct : bool ,
2728 is_public : bool ,
2829 is_space : bool ,
29- is_tombstoned : bool ,
30+ /// If present, it means the room has been archived/upgraded.
31+ tombstone : Option < RoomTombstoneInfo > ,
3032 is_favourite : bool ,
3133 canonical_alias : Option < String > ,
3234 alternative_aliases : Vec < String > ,
@@ -94,7 +96,7 @@ impl RoomInfo {
9496 is_direct : room. is_direct ( ) . await ?,
9597 is_public : room. is_public ( ) ,
9698 is_space : room. is_space ( ) ,
97- is_tombstoned : room. is_tombstoned ( ) ,
99+ tombstone : room. tombstone ( ) . map ( Into :: into ) ,
98100 is_favourite : room. is_favourite ( ) ,
99101 canonical_alias : room. canonical_alias ( ) . map ( Into :: into) ,
100102 alternative_aliases : room. alt_aliases ( ) . into_iter ( ) . map ( Into :: into) . collect ( ) ,
@@ -137,3 +139,17 @@ impl RoomInfo {
137139 } )
138140 }
139141}
142+
143+ /// Contains the `m.room.tombstone` state of the room, with a message about the
144+ /// room upgrade and the id of the newly created room to replace this one.
145+ #[ derive( uniffi:: Record ) ]
146+ pub struct RoomTombstoneInfo {
147+ body : String ,
148+ replacement_room_id : String ,
149+ }
150+
151+ impl From < ruma:: events:: room:: tombstone:: RoomTombstoneEventContent > for RoomTombstoneInfo {
152+ fn from ( value : RoomTombstoneEventContent ) -> Self {
153+ Self { body : value. body , replacement_room_id : value. replacement_room . to_string ( ) }
154+ }
155+ }
0 commit comments