mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Merge pull request #879 from teloxide/empty_message
Fix deserialization of empty messages
This commit is contained in:
commit
b7c1cd9494
2 changed files with 16 additions and 0 deletions
|
@ -56,8 +56,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Deserialization of `ApiError::CantParseEntities` ([#839][pr839])
|
||||
- Deserialization of empty (content-less) messages that can sometimes appear as a part of callback query ([#850][pr850], issue [#873][issue873])
|
||||
|
||||
[pr839]: https://github.com/teloxide/teloxide/pull/839
|
||||
[pr879]: https://github.com/teloxide/teloxide/pull/879
|
||||
[issue873]: https://github.com/teloxide/teloxide/issues/873
|
||||
|
||||
## 0.9.1 - 2023-02-15
|
||||
|
||||
|
|
|
@ -78,6 +78,9 @@ pub enum MessageKind {
|
|||
VideoChatEnded(MessageVideoChatEnded),
|
||||
VideoChatParticipantsInvited(MessageVideoChatParticipantsInvited),
|
||||
WebAppData(MessageWebAppData),
|
||||
/// An empty, content-less message, that can appear in callback queries
|
||||
/// attached to old messages.
|
||||
Empty {},
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
|
@ -1446,6 +1449,7 @@ impl Message {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use cool_asserts::assert_matches;
|
||||
use serde_json::from_str;
|
||||
|
||||
use crate::types::*;
|
||||
|
@ -1920,4 +1924,13 @@ mod tests {
|
|||
|
||||
let _: Message = serde_json::from_str(json).unwrap();
|
||||
}
|
||||
|
||||
/// Regression test for <https://github.com/teloxide/teloxide/issues/873>
|
||||
#[test]
|
||||
fn empty_message() {
|
||||
let json = r#"{"chat": {"first_name": "FN", "id": 1234567890, "type": "private"}, "date": 0, "message_id": 875400}"#;
|
||||
|
||||
let msg: Message = serde_json::from_str(json).unwrap();
|
||||
assert_matches!(msg.kind, MessageKind::Empty {})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue