Move deserialization prefix for giveaway_message_id field to types module

because it will be used in `ChatBoostSourceGiveaway` later
This commit is contained in:
Andrey Brusnik 2024-07-19 14:20:40 +04:00
parent 1abf1fa519
commit e5edaceb22
No known key found for this signature in database
GPG key ID: D33232F28CFF442C
2 changed files with 6 additions and 4 deletions

View file

@ -306,6 +306,11 @@ pub use recipient::*;
pub use seconds::*; pub use seconds::*;
pub use user_id::*; pub use user_id::*;
use serde_with::with_prefix;
// Deserialization prefix for giveaway_message_id field used in GiveawayWinners
with_prefix!(prefix_giveaway_message_id "giveaway_");
/// Converts an `i64` timestamp to a `choro::DateTime`, producing serde error /// Converts an `i64` timestamp to a `choro::DateTime`, producing serde error
/// for invalid timestamps /// for invalid timestamps
pub(crate) fn serde_timestamp<E: serde::de::Error>( pub(crate) fn serde_timestamp<E: serde::de::Error>(

View file

@ -1,11 +1,8 @@
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_with::with_prefix;
use crate::types::{Chat, MessageId, User}; use crate::types::{Chat, MessageId, User};
with_prefix!(prefix_giveaway "giveaway_");
/// This object represents a message about the completion of a giveaway with /// This object represents a message about the completion of a giveaway with
/// public winners. /// public winners.
#[serde_with::skip_serializing_none] #[serde_with::skip_serializing_none]
@ -15,7 +12,7 @@ pub struct GiveawayWinners {
pub chat: Chat, pub chat: Chat,
/// Identifier of the messsage with the giveaway in the chat /// Identifier of the messsage with the giveaway in the chat
#[serde(flatten, with = "prefix_giveaway")] #[serde(flatten, with = "crate::types::prefix_giveaway_message_id")]
pub giveaway_message_id: MessageId, pub giveaway_message_id: MessageId,
/// Point in time (Unix timestamp) when winners of the giveaway were /// Point in time (Unix timestamp) when winners of the giveaway were