client-api: Implement reasons for leaving a room
This commit is contained in:
		
							parent
							
								
									696c9fba4e
								
							
						
					
					
						commit
						13af2e235d
					
				| @ -8,6 +8,7 @@ Improvements: | ||||
|   r0::knock::knock_room | ||||
|   ``` | ||||
| * Add unstable support for room knocking. | ||||
| * Add unstable support for reasons for leaving rooms | ||||
| 
 | ||||
| # 0.11.0 | ||||
| 
 | ||||
|  | ||||
| @ -17,6 +17,12 @@ ruma_api! { | ||||
|         /// The room to leave.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|         /// Optional reason to be included as the `reason` on the subsequent membership event.
 | ||||
|         #[cfg(feature = "unstable-pre-spec")] | ||||
|         #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[derive(Default)] | ||||
| @ -28,7 +34,11 @@ ruma_api! { | ||||
| impl<'a> Request<'a> { | ||||
|     /// Creates a new `Request` with the given room id.
 | ||||
|     pub fn new(room_id: &'a RoomId) -> Self { | ||||
|         Self { room_id } | ||||
|         Self { | ||||
|             room_id, | ||||
|             #[cfg(feature = "unstable-pre-spec")] | ||||
|             reason: None, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -79,6 +79,12 @@ pub struct MemberEventContent { | ||||
|     #[serde(rename = "xyz.amorgan.blurhash")] | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub blurhash: Option<String>, | ||||
| 
 | ||||
|     /// The reason for leaving a room.
 | ||||
|     #[cfg(feature = "unstable-pre-spec")] | ||||
|     #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub reason: Option<String>, | ||||
| } | ||||
| 
 | ||||
| impl MemberEventContent { | ||||
| @ -92,6 +98,8 @@ impl MemberEventContent { | ||||
|             third_party_invite: None, | ||||
|             #[cfg(feature = "unstable-pre-spec")] | ||||
|             blurhash: None, | ||||
|             #[cfg(feature = "unstable-pre-spec")] | ||||
|             reason: None, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -241,6 +249,8 @@ fn membership_change( | ||||
|             third_party_invite: None, | ||||
|             #[cfg(feature = "unstable-pre-spec")] | ||||
|             blurhash: None, | ||||
|             #[cfg(feature = "unstable-pre-spec")] | ||||
|             reason: None, | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user