From b7456e425bc8bc1dd94c10c4b8f18fa2ae7b289b Mon Sep 17 00:00:00 2001 From: Mikhail Trishchenkov Date: Tue, 3 Oct 2023 17:59:53 +0700 Subject: [PATCH] Parse 'kicked' chat member status --- src/objects.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/objects.rs b/src/objects.rs index 4c2a7ca..d1c50c2 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -39,6 +39,7 @@ pub enum ChatMember { Member(ChatMemberMember), Restricted(ChatMemberRestricted), Left(ChatMemberLeft), + #[serde(rename = "kicked")] Banned(ChatMemberBanned), } @@ -3329,4 +3330,20 @@ mod serde_tests { assert_eq!(update, expected); } + + #[test] + pub fn kicked_user_status_is_parsed() { + let member_content = r#"{ + "status": "kicked", + "until_date": 0, + "user": { + "id": 0, + "is_bot": false, + "first_name": "First" + } + }"#; + + let member: ChatMember = serde_json::from_str(member_content).unwrap(); + assert!(matches!(member, ChatMember::Banned(_))); + } }