Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Fix deserialization of VoiceChat{Started,Ended} messages #153

Merged
merged 1 commit into from
Dec 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Type of response for `CopyMessage` method ([#141](pr141), [#142](pr142))
- Bad request serialization when the `language` field of `MessageEntityKind::Pre` is `None` ([#145](pr145))
- Deserialization of `MediaKind::Venue` ([#147][pr147])
- Deserialization of `VoiceChat{Started,Ended}` messages ([#153][pr153])

[pr119]: https://github.com/teloxide/teloxide-core/pull/119
[pr133]: https://github.com/teloxide/teloxide-core/pull/133
Expand All @@ -62,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[pr143]: https://github.com/teloxide/teloxide-core/pull/143
[pr145]: https://github.com/teloxide/teloxide-core/pull/145
[pr147]: https://github.com/teloxide/teloxide-core/pull/147
[pr153]: https://github.com/teloxide/teloxide-core/pull/153
[issue473]: https://github.com/teloxide/teloxide/issues/473
[issue427]: https://github.com/teloxide/teloxide/issues/427

Expand Down
14 changes: 14 additions & 0 deletions src/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,4 +1393,18 @@ mod tests {
}
)
}

/// Regression test for <https://github.com/teloxide/teloxide/issues/475>
#[test]
fn issue_475() {
let json = r#"{"message_id":198295,"from":{"id":1087968824,"is_bot":true,"first_name":"Group","username":"GroupAnonymousBot"},"sender_chat":{"id":-1001331354980,"title":"C++ Together 2.0","username":"cpptogether","type":"supergroup"},"chat":{"id":-1001331354980,"title":"C++ Together 2.0","username":"cpptogether","type":"supergroup"},"date":1638236631,"voice_chat_started":{}}"#;

let message: Message = serde_json::from_str(json).unwrap();

assert!(matches!(message.kind, MessageKind::VoiceChatStarted { .. }));

// FIXME(waffle): it seems like we are losing `sender_chat` in some
// cases inclusing this
// assert!(message.sender_chat().is_some());
}
}
2 changes: 1 addition & 1 deletion src/types/voice_chat_ended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat ended in the
/// chat.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatEnded;
pub struct VoiceChatEnded {}
2 changes: 1 addition & 1 deletion src/types/voice_chat_started.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ use serde::{Deserialize, Serialize};
/// This object represents a service message about a voice chat started in the
/// chat. Currently holds no information.
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct VoiceChatStarted;
pub struct VoiceChatStarted {}