@@ -515,6 +515,7 @@ pub struct RoomInfo {
515515 /// The unique room id of the room.
516516 pub ( crate ) room_id : Arc < RoomId > ,
517517 /// The state of the room.
518+ #[ serde( rename = "room_type" ) ] // for backwards compatibility
518519 room_state : RoomState ,
519520 /// The unread notifications counts.
520521 notification_counts : UnreadNotificationsCount ,
@@ -820,6 +821,65 @@ mod test {
820821 MinimalStateEvent , OriginalMinimalStateEvent ,
821822 } ;
822823
824+ #[ test]
825+ fn room_info_serialization ( ) {
826+ // This test exists to make sure we don't accidentally change the
827+ // serialized format for `RoomInfo`.
828+
829+ let info = RoomInfo {
830+ room_id : room_id ! ( "!gda78o:server.tld" ) . into ( ) ,
831+ room_state : RoomState :: Invited ,
832+ notification_counts : UnreadNotificationsCount {
833+ highlight_count : 1 ,
834+ notification_count : 2 ,
835+ } ,
836+ summary : RoomSummary {
837+ heroes : vec ! [ "Somebody" . to_owned( ) ] ,
838+ joined_member_count : 5 ,
839+ invited_member_count : 0 ,
840+ } ,
841+ members_synced : true ,
842+ last_prev_batch : Some ( "pb" . to_owned ( ) ) ,
843+ sync_info : SyncInfo :: FullySynced ,
844+ encryption_state_synced : true ,
845+ base_info : BaseRoomInfo :: new ( ) ,
846+ } ;
847+
848+ let info_json = json ! ( {
849+ "room_id" : "!gda78o:server.tld" ,
850+ "room_type" : "Invited" ,
851+ "notification_counts" : {
852+ "highlight_count" : 1 ,
853+ "notification_count" : 2 ,
854+ } ,
855+ "summary" : {
856+ "heroes" : [ "Somebody" ] ,
857+ "joined_member_count" : 5 ,
858+ "invited_member_count" : 0 ,
859+ } ,
860+ "members_synced" : true ,
861+ "last_prev_batch" : "pb" ,
862+ "sync_info" : "FullySynced" ,
863+ "encryption_state_synced" : true ,
864+ "base_info" : {
865+ "avatar" : null,
866+ "canonical_alias" : null,
867+ "create" : null,
868+ "dm_targets" : [ ] ,
869+ "encryption" : null,
870+ "guest_access" : null,
871+ "history_visibility" : null,
872+ "join_rules" : null,
873+ "max_power_level" : 100 ,
874+ "name" : null,
875+ "tombstone" : null,
876+ "topic" : null,
877+ }
878+ } ) ;
879+
880+ assert_eq ! ( serde_json:: to_value( info) . unwrap( ) , info_json) ;
881+ }
882+
823883 fn make_room ( room_type : RoomState ) -> ( Arc < MemoryStore > , Room ) {
824884 let store = Arc :: new ( MemoryStore :: new ( ) ) ;
825885 let user_id = user_id ! ( "@me:example.org" ) ;
0 commit comments