directory: Stabilize room_types and room_type for /publicRooms
This commit is contained in:
		
							parent
							
								
									fa64b36c11
								
							
						
					
					
						commit
						f068c3fb5a
					
				| @ -10,6 +10,7 @@ Improvements: | |||||||
| 
 | 
 | ||||||
| * Add `MatrixVersion::V1_4` | * Add `MatrixVersion::V1_4` | ||||||
| * Stabilize default room server ACL push rule | * Stabilize default room server ACL push rule | ||||||
|  | * Stabilize `room_types` in `directory::Filter` and `room_type` in `directory::PublicRoomsChunk` | ||||||
| 
 | 
 | ||||||
| # 0.10.3 | # 0.10.3 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -47,7 +47,6 @@ unstable-msc3551 = ["unstable-msc1767"] | |||||||
| unstable-msc3552 = ["unstable-msc3551"] | unstable-msc3552 = ["unstable-msc3551"] | ||||||
| unstable-msc3553 = ["unstable-msc3552"] | unstable-msc3553 = ["unstable-msc3552"] | ||||||
| unstable-msc3554 = ["unstable-msc1767"] | unstable-msc3554 = ["unstable-msc1767"] | ||||||
| unstable-msc3827 = [] |  | ||||||
| unstable-pdu = [] | unstable-pdu = [] | ||||||
| unstable-sanitize = ["dep:html5ever", "dep:phf"] | unstable-sanitize = ["dep:html5ever", "dep:phf"] | ||||||
| unstable-unspecified = [] | unstable-unspecified = [] | ||||||
|  | |||||||
| @ -3,13 +3,11 @@ | |||||||
| use js_int::UInt; | use js_int::UInt; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| 
 | 
 | ||||||
| #[cfg(feature = "unstable-msc3827")] |  | ||||||
| mod filter_room_type_serde; | mod filter_room_type_serde; | ||||||
| mod room_network_serde; | mod room_network_serde; | ||||||
| 
 | 
 | ||||||
| #[cfg(feature = "unstable-msc3827")] |  | ||||||
| use crate::room::RoomType; |  | ||||||
| use crate::{ | use crate::{ | ||||||
|  |     room::RoomType, | ||||||
|     serde::{Incoming, StringEnum}, |     serde::{Incoming, StringEnum}, | ||||||
|     OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, PrivOwnedStr, |     OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, PrivOwnedStr, | ||||||
| }; | }; | ||||||
| @ -67,16 +65,7 @@ pub struct PublicRoomsChunk { | |||||||
|     pub join_rule: PublicRoomJoinRule, |     pub join_rule: PublicRoomJoinRule, | ||||||
| 
 | 
 | ||||||
|     /// The type of room from `m.room.create`, if any.
 |     /// The type of room from `m.room.create`, if any.
 | ||||||
|     ///
 |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|     /// This field uses the unstable prefix from [MSC3827].
 |  | ||||||
|     ///
 |  | ||||||
|     /// [MSC3827]: https://github.com/matrix-org/matrix-spec-proposals/pull/3827
 |  | ||||||
|     #[cfg(feature = "unstable-msc3827")] |  | ||||||
|     #[serde(
 |  | ||||||
|         rename = "org.matrix.msc3827.room_type", |  | ||||||
|         alias = "room_type", |  | ||||||
|         skip_serializing_if = "Option::is_none" |  | ||||||
|     )] |  | ||||||
|     pub room_type: Option<RoomType>, |     pub room_type: Option<RoomType>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -117,7 +106,6 @@ impl From<PublicRoomsChunkInit> for PublicRoomsChunk { | |||||||
|             guest_can_join, |             guest_can_join, | ||||||
|             avatar_url: None, |             avatar_url: None, | ||||||
|             join_rule: PublicRoomJoinRule::default(), |             join_rule: PublicRoomJoinRule::default(), | ||||||
|             #[cfg(feature = "unstable-msc3827")] |  | ||||||
|             room_type: None, |             room_type: None, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -135,17 +123,7 @@ pub struct Filter<'a> { | |||||||
|     /// The room types to include in the results.
 |     /// The room types to include in the results.
 | ||||||
|     ///
 |     ///
 | ||||||
|     /// Includes all room types if it is empty.
 |     /// Includes all room types if it is empty.
 | ||||||
|     ///
 |     #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||||||
|     /// This field uses the unstable prefix from [MSC3827].
 |  | ||||||
|     ///
 |  | ||||||
|     /// [MSC3827]: https://github.com/matrix-org/matrix-spec-proposals/pull/3827
 |  | ||||||
|     #[cfg(feature = "unstable-msc3827")] |  | ||||||
|     #[serde(
 |  | ||||||
|         rename = "org.matrix.msc3827.room_types", |  | ||||||
|         alias = "room_types", |  | ||||||
|         default, |  | ||||||
|         skip_serializing_if = "Vec::is_empty" |  | ||||||
|     )] |  | ||||||
|     pub room_types: Vec<RoomTypeFilter>, |     pub room_types: Vec<RoomTypeFilter>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -208,7 +186,6 @@ pub enum PublicRoomJoinRule { | |||||||
| ///
 | ///
 | ||||||
| /// To check for values that are not available as a documented variant here, use its string
 | /// To check for values that are not available as a documented variant here, use its string
 | ||||||
| /// representation, obtained through [`.as_str()`](Self::as_str()).
 | /// representation, obtained through [`.as_str()`](Self::as_str()).
 | ||||||
| #[cfg(feature = "unstable-msc3827")] |  | ||||||
| #[derive(Clone, Debug, PartialEq, Eq)] | #[derive(Clone, Debug, PartialEq, Eq)] | ||||||
| #[non_exhaustive] | #[non_exhaustive] | ||||||
| pub enum RoomTypeFilter { | pub enum RoomTypeFilter { | ||||||
| @ -223,7 +200,6 @@ pub enum RoomTypeFilter { | |||||||
|     _Custom(PrivOwnedStr), |     _Custom(PrivOwnedStr), | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[cfg(feature = "unstable-msc3827")] |  | ||||||
| impl RoomTypeFilter { | impl RoomTypeFilter { | ||||||
|     /// Get the string representation of this `RoomTypeFilter`.
 |     /// Get the string representation of this `RoomTypeFilter`.
 | ||||||
|     ///
 |     ///
 | ||||||
| @ -237,7 +213,6 @@ impl RoomTypeFilter { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[cfg(feature = "unstable-msc3827")] |  | ||||||
| impl<T> From<Option<T>> for RoomTypeFilter | impl<T> From<Option<T>> for RoomTypeFilter | ||||||
| where | where | ||||||
|     T: AsRef<str> + Into<Box<str>>, |     T: AsRef<str> + Into<Box<str>>, | ||||||
| @ -255,13 +230,10 @@ where | |||||||
| 
 | 
 | ||||||
| #[cfg(test)] | #[cfg(test)] | ||||||
| mod tests { | mod tests { | ||||||
|     #[cfg(feature = "unstable-msc3827")] |  | ||||||
|     use assert_matches::assert_matches; |     use assert_matches::assert_matches; | ||||||
|     use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; |     use serde_json::{from_value as from_json_value, json, to_value as to_json_value}; | ||||||
| 
 | 
 | ||||||
|     #[cfg(feature = "unstable-msc3827")] |     use super::{Filter, IncomingFilter, IncomingRoomNetwork, RoomNetwork, RoomTypeFilter}; | ||||||
|     use super::RoomTypeFilter; |  | ||||||
|     use super::{Filter, IncomingFilter, IncomingRoomNetwork, RoomNetwork}; |  | ||||||
| 
 | 
 | ||||||
|     #[test] |     #[test] | ||||||
|     fn serialize_matrix_network_only() { |     fn serialize_matrix_network_only() { | ||||||
| @ -341,11 +313,9 @@ mod tests { | |||||||
|         let json = json!({}); |         let json = json!({}); | ||||||
|         let filter = from_json_value::<IncomingFilter>(json).unwrap(); |         let filter = from_json_value::<IncomingFilter>(json).unwrap(); | ||||||
|         assert_eq!(filter.generic_search_term, None); |         assert_eq!(filter.generic_search_term, None); | ||||||
|         #[cfg(feature = "unstable-msc3827")] |  | ||||||
|         assert_eq!(filter.room_types.len(), 0); |         assert_eq!(filter.room_types.len(), 0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     #[cfg(feature = "unstable-msc3827")] |  | ||||||
|     #[test] |     #[test] | ||||||
|     fn serialize_filter_room_types() { |     fn serialize_filter_room_types() { | ||||||
|         let filter = Filter { |         let filter = Filter { | ||||||
| @ -356,25 +326,12 @@ mod tests { | |||||||
|                 Some("custom_type").into(), |                 Some("custom_type").into(), | ||||||
|             ], |             ], | ||||||
|         }; |         }; | ||||||
|         let json = json!({ "org.matrix.msc3827.room_types": [null, "m.space", "custom_type"] }); |         let json = json!({ "room_types": [null, "m.space", "custom_type"] }); | ||||||
|         assert_eq!(to_json_value(filter).unwrap(), json); |         assert_eq!(to_json_value(filter).unwrap(), json); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     #[cfg(feature = "unstable-msc3827")] |  | ||||||
|     #[test] |     #[test] | ||||||
|     fn deserialize_filter_room_types_unstable() { |     fn deserialize_filter_room_types() { | ||||||
|         let json = json!({ "org.matrix.msc3827.room_types": [null, "m.space", "custom_type"] }); |  | ||||||
|         let filter = from_json_value::<IncomingFilter>(json).unwrap(); |  | ||||||
|         assert_eq!(filter.room_types.len(), 3); |  | ||||||
|         assert_eq!(filter.room_types[0], RoomTypeFilter::Default); |  | ||||||
|         assert_eq!(filter.room_types[1], RoomTypeFilter::Space); |  | ||||||
|         assert_matches!(filter.room_types[2], RoomTypeFilter::_Custom(_)); |  | ||||||
|         assert_eq!(filter.room_types[2].as_str(), Some("custom_type")); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     #[cfg(feature = "unstable-msc3827")] |  | ||||||
|     #[test] |  | ||||||
|     fn deserialize_filter_room_types_stable() { |  | ||||||
|         let json = json!({ "room_types": [null, "m.space", "custom_type"] }); |         let json = json!({ "room_types": [null, "m.space", "custom_type"] }); | ||||||
|         let filter = from_json_value::<IncomingFilter>(json).unwrap(); |         let filter = from_json_value::<IncomingFilter>(json).unwrap(); | ||||||
|         assert_eq!(filter.room_types.len(), 3); |         assert_eq!(filter.room_types.len(), 3); | ||||||
|  | |||||||
| @ -157,7 +157,6 @@ unstable-msc3554 = ["ruma-common/unstable-msc3554"] | |||||||
| unstable-msc3575 = ["ruma-client-api?/unstable-msc3575"] | unstable-msc3575 = ["ruma-client-api?/unstable-msc3575"] | ||||||
| unstable-msc3618 = ["ruma-federation-api?/unstable-msc3618"] | unstable-msc3618 = ["ruma-federation-api?/unstable-msc3618"] | ||||||
| unstable-msc3723 = ["ruma-federation-api?/unstable-msc3723"] | unstable-msc3723 = ["ruma-federation-api?/unstable-msc3723"] | ||||||
| unstable-msc3827 = ["ruma-common/unstable-msc3827"] |  | ||||||
| unstable-pdu = ["ruma-common/unstable-pdu"] | unstable-pdu = ["ruma-common/unstable-pdu"] | ||||||
| unstable-sanitize = ["ruma-common/unstable-sanitize"] | unstable-sanitize = ["ruma-common/unstable-sanitize"] | ||||||
| unstable-unspecified = [ | unstable-unspecified = [ | ||||||
| @ -194,7 +193,6 @@ __ci = [ | |||||||
|     "unstable-msc3575", |     "unstable-msc3575", | ||||||
|     "unstable-msc3618", |     "unstable-msc3618", | ||||||
|     "unstable-msc3723", |     "unstable-msc3723", | ||||||
|     "unstable-msc3827", |  | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user