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 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
/// for invalid timestamps
pub(crate) fn serde_timestamp<E: serde::de::Error>(

View file

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