mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-22 06:45:37 +01:00
Fix deserialization of empty messages
This commit is contained in:
parent
387f6d1284
commit
97247ecbfb
2 changed files with 16 additions and 0 deletions
|
@ -32,8 +32,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Deserialization of `ApiError::CantParseEntities` ([#839][pr839])
|
- 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
|
[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
|
## 0.9.1 - 2023-02-15
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,9 @@ pub enum MessageKind {
|
||||||
VideoChatEnded(MessageVideoChatEnded),
|
VideoChatEnded(MessageVideoChatEnded),
|
||||||
VideoChatParticipantsInvited(MessageVideoChatParticipantsInvited),
|
VideoChatParticipantsInvited(MessageVideoChatParticipantsInvited),
|
||||||
WebAppData(MessageWebAppData),
|
WebAppData(MessageWebAppData),
|
||||||
|
/// An empty, content-less message, that can appear in callback queries
|
||||||
|
/// attached to old messages.
|
||||||
|
Empty {},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[serde_with_macros::skip_serializing_none]
|
#[serde_with_macros::skip_serializing_none]
|
||||||
|
@ -1446,6 +1449,7 @@ impl Message {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use cool_asserts::assert_matches;
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
|
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
@ -1920,4 +1924,13 @@ mod tests {
|
||||||
|
|
||||||
let _: Message = serde_json::from_str(json).unwrap();
|
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…
Add table
Reference in a new issue