Skip to content

Commit

Permalink
Accept unknown message entity types (#146)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Trishchenkov <[email protected]>
  • Loading branch information
kriomant and Mikhail Trishchenkov authored Feb 12, 2024
1 parent c750c87 commit f1122b7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub enum MessageEntityType {
TextMention,
CustomEmoji,
Blockquote,
#[serde(other)]
Unknown,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -3793,4 +3795,22 @@ mod serde_tests {
let member: ChatMember = serde_json::from_str(member_content).unwrap();
assert!(matches!(member, ChatMember::Kicked(_)));
}

#[test]
pub fn unknown_entity_kind_is_parsed() {
let entity_content = r#"{
"type": "__unknown__",
"offset": 10,
"length": 20
}"#;

let entity: MessageEntity = serde_json::from_str(entity_content).unwrap();
assert!(matches!(
entity,
MessageEntity {
type_field: MessageEntityType::Unknown,
..
}
));
}
}

0 comments on commit f1122b7

Please sign in to comment.