diff --git a/crates/teloxide-core/src/types/business_connection_id.rs b/crates/teloxide-core/src/types/business_connection_id.rs index 982a3f66..672caddf 100644 --- a/crates/teloxide-core/src/types/business_connection_id.rs +++ b/crates/teloxide-core/src/types/business_connection_id.rs @@ -2,33 +2,15 @@ use serde::{Deserialize, Serialize}; /// A unique business connection identifier. #[derive(Default, Clone, Debug, derive_more::Display, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[serde(from = "BusinessConnectionIdRaw", into = "BusinessConnectionIdRaw")] pub struct BusinessConnectionId(pub String); -#[derive(Serialize, Deserialize)] -struct BusinessConnectionIdRaw { - business_connection_id: String, -} - -impl From for BusinessConnectionId { - fn from(BusinessConnectionIdRaw { business_connection_id }: BusinessConnectionIdRaw) -> Self { - BusinessConnectionId(business_connection_id) - } -} - -impl From for BusinessConnectionIdRaw { - fn from(BusinessConnectionId(business_connection_id): BusinessConnectionId) -> Self { - BusinessConnectionIdRaw { business_connection_id } - } -} - #[cfg(test)] mod tests { use crate::types::BusinessConnectionId; #[test] fn business_connection_id_deser() { - let json = r#"{"business_connection_id": "abcd1234"}"#; + let json = r#""abcd1234""#; let bcid: BusinessConnectionId = serde_json::from_str(json).unwrap(); assert_eq!(bcid, BusinessConnectionId(String::from("abcd1234"))); } @@ -37,6 +19,6 @@ mod tests { fn business_connection_id_ser() { let bcid: BusinessConnectionId = BusinessConnectionId(String::from("abcd1234")); let json = serde_json::to_string(&bcid).unwrap(); - assert_eq!(json, r#"{"business_connection_id":"abcd1234"}"#); + assert_eq!(json, r#""abcd1234""#); } } diff --git a/crates/teloxide-core/src/types/business_messages_deleted.rs b/crates/teloxide-core/src/types/business_messages_deleted.rs index 3c84daea..ec5a6b4d 100644 --- a/crates/teloxide-core/src/types/business_messages_deleted.rs +++ b/crates/teloxide-core/src/types/business_messages_deleted.rs @@ -7,6 +7,7 @@ use crate::types::{BusinessConnectionId, Chat, MessageId}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct BusinessMessagesDeleted { /// Unique identifier of the business connection. + #[serde(flatten)] pub business_connection_id: BusinessConnectionId, /// Information about a chat in the business account. The bot may not have diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index 2b2ce6e2..95a6d615 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -169,6 +169,7 @@ pub struct MessageCommon { /// received. If non-empty, the message belongs to a chat of the /// corresponding business account that is independent from any potential /// bot chat which might share the same identifier. + #[serde(flatten)] pub business_connection_id: Option, } diff --git a/crates/teloxide-core/src/types/update.rs b/crates/teloxide-core/src/types/update.rs index b6707c2b..dd06de27 100644 --- a/crates/teloxide-core/src/types/update.rs +++ b/crates/teloxide-core/src/types/update.rs @@ -1007,7 +1007,7 @@ mod test { "#; let chat = Chat { id: ChatId(-1002199793788), - kind: ChatKind::Public(ChatPublic { + kind: ChatKind::Public(Box::new(ChatPublic { title: Some("ั‚ะตัั‚".to_owned()), kind: PublicChatKind::Supergroup(PublicChatSupergroup { username: None, @@ -1027,7 +1027,7 @@ mod test { description: None, invite_link: None, has_protected_content: None, - }), + })), photo: None, available_reactions: None, pinned_message: None,