diff --git a/crates/teloxide-core/CHANGELOG.md b/crates/teloxide-core/CHANGELOG.md index 6186966f..14289dd8 100644 --- a/crates/teloxide-core/CHANGELOG.md +++ b/crates/teloxide-core/CHANGELOG.md @@ -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 diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index 2c6403d8..ced7ba07 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -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 + #[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 {}) + } }