mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Fix serde support for some types from TBA 6.8
This commit is contained in:
parent
c38ff2404a
commit
769128287e
2 changed files with 26 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// TODO: in the TBA7.3 the Chat will be splitted into Chat and ChatInfo
|
||||
|
@ -5,8 +6,30 @@ use serde::{Deserialize, Serialize};
|
|||
#[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<i64>,
|
||||
#[serde(default, with = "crate::types::serde_opt_date_from_unix_timestamp")]
|
||||
pub emoji_status_expiration_date: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_chat_full_info_de() {
|
||||
assert_eq!(
|
||||
serde_json::from_str::<ChatFullInfo>("{}").unwrap(),
|
||||
ChatFullInfo { emoji_status_expiration_date: None }
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_str::<ChatFullInfo>(
|
||||
r#"{
|
||||
"emoji_status_expiration_date": 1720708004
|
||||
}"#
|
||||
)
|
||||
.unwrap(),
|
||||
ChatFullInfo { emoji_status_expiration_date: DateTime::from_timestamp(1720708004, 0) }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
/// TBA 6.8: currently it holds no information
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Story;
|
||||
pub struct Story {}
|
||||
|
|
Loading…
Reference in a new issue