Fix parsing pinned_message

Related to https://github.com/teloxide/teloxide/issues/167.
This commit is contained in:
Temirkhan Myrzamadi 2020-02-20 21:22:36 +06:00
parent 93afb0b611
commit 29ed9a1ffe
2 changed files with 43 additions and 0 deletions

View file

@ -113,6 +113,7 @@ pub enum MessageKind {
/// Specified message was pinned. Note that the Message object in this
/// field will not contain further `reply_to_message` fields even if it
/// is itself a reply.
#[serde(rename = "pinned_message")]
pinned: Box<Message>,
},
Invoice {

View file

@ -205,4 +205,46 @@ mod test {
assert!(serde_json::from_str::<Update>(text).is_ok());
}
#[test]
fn pinned_message_works() {
let json = r#"{
"message": {
"chat": {
"id": -1001276785818,
"title": "teloxide dev",
"type": "supergroup",
"username": "teloxide_dev"
},
"date": 1582134655,
"from": {
"first_name": "Hirrolot",
"id": 408258968,
"is_bot": false,
"username": "hirrolot"
},
"message_id": 20225,
"pinned_message": {
"chat": {
"id": -1001276785818,
"title": "teloxide dev",
"type": "supergroup",
"username": "teloxide_dev"
},
"date": 1582134643,
"from": {
"first_name": "Hirrolot",
"id": 408258968,
"is_bot": false,
"username": "hirrolot"
},
"message_id": 20224,
"text": "Faster than a bullet"
}
},
"update_id": 845402291
}"#;
serde_json::from_str::<Update>(json).unwrap();
}
}