diff --git a/crates/teloxide-core/src/types.rs b/crates/teloxide-core/src/types.rs index 2b2a926b..f142825d 100644 --- a/crates/teloxide-core/src/types.rs +++ b/crates/teloxide-core/src/types.rs @@ -13,6 +13,7 @@ pub use callback_query::*; pub use chat::*; pub use chat_action::*; pub use chat_administrator_rights::*; +pub use chat_full_info::*; pub use chat_invite_link::*; pub use chat_join_request::*; pub use chat_location::*; @@ -142,6 +143,7 @@ mod callback_query; mod chat; mod chat_action; mod chat_administrator_rights; +mod chat_full_info; mod chat_invite_link; mod chat_join_request; mod chat_location; diff --git a/crates/teloxide-core/src/types/chat.rs b/crates/teloxide-core/src/types/chat.rs index 2bd38dd9..6f12745d 100644 --- a/crates/teloxide-core/src/types/chat.rs +++ b/crates/teloxide-core/src/types/chat.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::types::{ - ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, Seconds, True, User, + ChatFullInfo, ChatId, ChatLocation, ChatPermissions, ChatPhoto, Message, Seconds, True, User, }; /// This object represents a chat. @@ -47,6 +47,9 @@ pub struct Chat { /// [`GetChat`]: crate::payloads::GetChat #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub has_aggressive_anti_spam_enabled: bool, + + #[serde(flatten)] + pub chat_full_info: ChatFullInfo, } #[serde_with_macros::skip_serializing_none] @@ -615,6 +618,7 @@ mod tests { message_auto_delete_time: None, has_hidden_members: false, has_aggressive_anti_spam_enabled: false, + chat_full_info: ChatFullInfo { emoji_status_expiration_date: None }, }; let actual = from_str(r#"{"id":-1,"type":"channel","username":"channel_name"}"#).unwrap(); assert_eq!(expected, actual); @@ -639,6 +643,7 @@ mod tests { message_auto_delete_time: None, has_hidden_members: false, has_aggressive_anti_spam_enabled: false, + chat_full_info: ChatFullInfo { emoji_status_expiration_date: None } }, from_str(r#"{"id":0,"type":"private","username":"username","first_name":"Anon"}"#) .unwrap() @@ -663,6 +668,7 @@ mod tests { message_auto_delete_time: None, has_hidden_members: false, has_aggressive_anti_spam_enabled: false, + chat_full_info: ChatFullInfo { emoji_status_expiration_date: None }, }; let json = to_string(&chat).unwrap(); diff --git a/crates/teloxide-core/src/types/chat_full_info.rs b/crates/teloxide-core/src/types/chat_full_info.rs new file mode 100644 index 00000000..3f5bc70c --- /dev/null +++ b/crates/teloxide-core/src/types/chat_full_info.rs @@ -0,0 +1,12 @@ +use serde::{Deserialize, Serialize}; + +// TODO: in the TBA7.3 the Chat will be splitted into Chat and ChatInfo +// Currently it's just a container for the some fields of the Chat struct +#[serde_with_macros::skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct ChatFullInfo { + // FIXME: better type for the unix timestamp? + /// Expiration date of the emoji status of the chat or the other party in a + /// private chat, in Unix time, if any + pub emoji_status_expiration_date: Option, +} diff --git a/crates/teloxide-core/src/types/message.rs b/crates/teloxide-core/src/types/message.rs index da36ebf9..0eb7f353 100644 --- a/crates/teloxide-core/src/types/message.rs +++ b/crates/teloxide-core/src/types/message.rs @@ -1783,7 +1783,8 @@ mod tests { has_aggressive_anti_spam_enabled: false, pinned_message: None, message_auto_delete_time: None, - has_hidden_members: false + has_hidden_members: false, + chat_full_info: ChatFullInfo { emoji_status_expiration_date: None } }, kind: MessageKind::ChatShared(MessageChatShared { chat_shared: ChatShared { request_id: 348349, chat_id: ChatId(384939) } @@ -2016,6 +2017,7 @@ mod tests { pinned_message: None, has_hidden_members: false, has_aggressive_anti_spam_enabled: false, + chat_full_info: ChatFullInfo { emoji_status_expiration_date: None }, }; assert!(message.from().unwrap().is_anonymous()); diff --git a/crates/teloxide-core/src/types/update.rs b/crates/teloxide-core/src/types/update.rs index 5f03f689..adc8056a 100644 --- a/crates/teloxide-core/src/types/update.rs +++ b/crates/teloxide-core/src/types/update.rs @@ -385,8 +385,8 @@ fn empty_error() -> UpdateKind { #[cfg(test)] mod test { use crate::types::{ - Chat, ChatId, ChatKind, ChatPrivate, MediaKind, MediaText, Message, MessageCommon, - MessageId, MessageKind, Update, UpdateId, UpdateKind, User, UserId, + Chat, ChatFullInfo, ChatId, ChatKind, ChatPrivate, MediaKind, MediaText, Message, + MessageCommon, MessageId, MessageKind, Update, UpdateId, UpdateKind, User, UserId, }; use chrono::DateTime; @@ -442,6 +442,7 @@ mod test { message_auto_delete_time: None, has_hidden_members: false, has_aggressive_anti_spam_enabled: false, + chat_full_info: ChatFullInfo { emoji_status_expiration_date: None }, }, kind: MessageKind::Common(MessageCommon { from: Some(User {