Fix a bunch more deserialization bugs
This commit is contained in:
		
							parent
							
								
									eca6d97690
								
							
						
					
					
						commit
						4a91932ea8
					
				| @ -24,7 +24,9 @@ pub struct Candidate { | |||||||
|     /// The SDP "a" line of the candidate.
 |     /// The SDP "a" line of the candidate.
 | ||||||
|     pub candidate: String, |     pub candidate: String, | ||||||
|     /// The SDP media type this candidate is intended for.
 |     /// The SDP media type this candidate is intended for.
 | ||||||
|  |     #[serde(rename = "sdpMid")] | ||||||
|     pub sdp_mid: String, |     pub sdp_mid: String, | ||||||
|     /// The index of the SDP "m" line this candidate is intended for.
 |     /// The index of the SDP "m" line this candidate is intended for.
 | ||||||
|  |     #[serde(rename = "sdpMLineIndex")] | ||||||
|     pub sdp_m_line_index: u64, |     pub sdp_m_line_index: u64, | ||||||
| } | } | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ pub mod invite; | |||||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | #[derive(Clone, Debug, Deserialize, Serialize)] | ||||||
| pub struct SessionDescription { | pub struct SessionDescription { | ||||||
|     /// The type of session description.
 |     /// The type of session description.
 | ||||||
|  |     #[serde(rename="type")] | ||||||
|     pub session_type: SessionDescriptionType, |     pub session_type: SessionDescriptionType, | ||||||
|     /// The SDP text of the session description.
 |     /// The SDP text of the session description.
 | ||||||
|     pub sdp: String, |     pub sdp: String, | ||||||
|  | |||||||
| @ -18,6 +18,7 @@ pub struct PresenceEventContent { | |||||||
|     pub avatar_url: Option<String>, |     pub avatar_url: Option<String>, | ||||||
| 
 | 
 | ||||||
|     /// Whether or not the user is currently active.
 |     /// Whether or not the user is currently active.
 | ||||||
|  |     #[serde(skip_serializing_if="Option::is_none")] | ||||||
|     pub currently_active: Option<bool>, |     pub currently_active: Option<bool>, | ||||||
| 
 | 
 | ||||||
|     /// The current display name for this user.
 |     /// The current display name for this user.
 | ||||||
|  | |||||||
| @ -23,6 +23,7 @@ pub type ReceiptEventContent = HashMap<EventId, Receipts>; | |||||||
| pub struct Receipts { | pub struct Receipts { | ||||||
|     /// A collection of users who have sent *m.read* receipts for this event.
 |     /// A collection of users who have sent *m.read* receipts for this event.
 | ||||||
|     #[serde(rename="m.read")] |     #[serde(rename="m.read")] | ||||||
|  |     #[serde(default)] | ||||||
|     pub m_read: UserReceipts, |     pub m_read: UserReceipts, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -13,11 +13,14 @@ state_event! { | |||||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | #[derive(Clone, Debug, Deserialize, Serialize)] | ||||||
| pub struct AvatarEventContent { | pub struct AvatarEventContent { | ||||||
|     /// Information about the avatar image.
 |     /// Information about the avatar image.
 | ||||||
|     pub info: ImageInfo, |     #[serde(skip_serializing_if="Option::is_none")] | ||||||
|  |     pub info: Option<ImageInfo>, | ||||||
|     /// Information about the avatar thumbnail image.
 |     /// Information about the avatar thumbnail image.
 | ||||||
|     pub thumbnail_info: ImageInfo, |     #[serde(skip_serializing_if="Option::is_none")] | ||||||
|  |     pub thumbnail_info: Option<ImageInfo>, | ||||||
|     /// URL of the avatar thumbnail image.
 |     /// URL of the avatar thumbnail image.
 | ||||||
|     pub thumbnail_url: String, |     #[serde(skip_serializing_if="Option::is_none")] | ||||||
|  |     pub thumbnail_url: Option<String>, | ||||||
|     /// URL of the avatar image.
 |     /// URL of the avatar image.
 | ||||||
|     pub url: String, |     pub url: String, | ||||||
| } | } | ||||||
|  | |||||||
| @ -21,11 +21,11 @@ pub mod topic; | |||||||
| #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] | #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] | ||||||
| pub struct ImageInfo { | pub struct ImageInfo { | ||||||
|     /// The height of the image in pixels.
 |     /// The height of the image in pixels.
 | ||||||
|     pub height: u64, |     pub h: u64, | ||||||
|     /// The MIME type of the image, e.g. "image/png."
 |     /// The MIME type of the image, e.g. "image/png."
 | ||||||
|     pub mimetype: String, |     pub mimetype: String, | ||||||
|     /// The file size of the image in bytes.
 |     /// The file size of the image in bytes.
 | ||||||
|     pub size: u64, |     pub size: u64, | ||||||
|     /// The width of the image in pixels.
 |     /// The width of the image in pixels.
 | ||||||
|     pub width: u64, |     pub w: u64, | ||||||
| } | } | ||||||
|  | |||||||
| @ -291,14 +291,14 @@ mod tests { | |||||||
|             "state_key": "", |             "state_key": "", | ||||||
|             "content": { |             "content": { | ||||||
|                 "info": { |                 "info": { | ||||||
|                     "height": 128, |                     "h": 128, | ||||||
|                     "width": 128, |                     "w": 128, | ||||||
|                     "mimetype": "image/jpeg", |                     "mimetype": "image/jpeg", | ||||||
|                     "size": 1024 |                     "size": 1024 | ||||||
|                 }, |                 }, | ||||||
|                 "thumbnail_info": { |                 "thumbnail_info": { | ||||||
|                     "height": 16, |                     "h": 16, | ||||||
|                     "width": 16, |                     "w": 16, | ||||||
|                     "mimetype": "image/jpeg", |                     "mimetype": "image/jpeg", | ||||||
|                     "size": 32 |                     "size": 32 | ||||||
|                 }, |                 }, | ||||||
| @ -331,11 +331,13 @@ mod tests { | |||||||
| 
 | 
 | ||||||
|         match from_str::<StrippedState>(avatar_event).unwrap() { |         match from_str::<StrippedState>(avatar_event).unwrap() { | ||||||
|             StrippedState::RoomAvatar(event) => { |             StrippedState::RoomAvatar(event) => { | ||||||
|                 assert_eq!(event.content.info.height, 128); |                 let image_info = event.content.info.unwrap(); | ||||||
|                 assert_eq!(event.content.info.width, 128); | 
 | ||||||
|                 assert_eq!(event.content.info.mimetype, "image/jpeg"); |                 assert_eq!(image_info.h, 128); | ||||||
|                 assert_eq!(event.content.info.size, 1024); |                 assert_eq!(image_info.w, 128); | ||||||
|                 assert_eq!(event.content.thumbnail_info.size, 32); |                 assert_eq!(image_info.mimetype, "image/jpeg"); | ||||||
|  |                 assert_eq!(image_info.size, 1024); | ||||||
|  |                 assert_eq!(event.content.thumbnail_info.unwrap().size, 32); | ||||||
|                 assert_eq!(event.content.url, "https://domain.com/image.jpg"); |                 assert_eq!(event.content.url, "https://domain.com/image.jpg"); | ||||||
|                 assert_eq!(event.event_type, EventType::RoomAvatar); |                 assert_eq!(event.event_type, EventType::RoomAvatar); | ||||||
|                 assert_eq!(event.state_key, ""); |                 assert_eq!(event.state_key, ""); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user