Fix ...Forum... messages deserialization

This commit is contained in:
Maybe Waffle 2023-01-14 20:17:20 +04:00
parent f624b9a996
commit be7b259adf

View file

@ -42,6 +42,9 @@ pub struct Message {
pub kind: MessageKind, pub kind: MessageKind,
} }
// FIXME: this could be a use-case for serde mixed-tags, some variants need to
// untagged (`MessageCommon` as an example), while other need to be
// tagged (e.g.: Forum*)
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum MessageKind { pub enum MessageKind {
@ -59,16 +62,16 @@ pub enum MessageKind {
Invoice(MessageInvoice), Invoice(MessageInvoice),
SuccessfulPayment(MessageSuccessfulPayment), SuccessfulPayment(MessageSuccessfulPayment),
ConnectedWebsite(MessageConnectedWebsite), ConnectedWebsite(MessageConnectedWebsite),
WriteAccessAllowed(WriteAccessAllowed), WriteAccessAllowed(MessageWriteAccessAllowed),
PassportData(MessagePassportData), PassportData(MessagePassportData),
Dice(MessageDice), Dice(MessageDice),
ProximityAlertTriggered(MessageProximityAlertTriggered), ProximityAlertTriggered(MessageProximityAlertTriggered),
ForumTopicCreated(ForumTopicCreated), ForumTopicCreated(MessageForumTopicCreated),
ForumTopicEdited(ForumTopicEdited), ForumTopicEdited(MessageForumTopicEdited),
ForumTopicClosed(ForumTopicClosed), ForumTopicClosed(MessageForumTopicClosed),
ForumTopicReopened(ForumTopicReopened), ForumTopicReopened(MessageForumTopicReopened),
GeneralForumTopicHidden(GeneralForumTopicHidden), GeneralForumTopicHidden(MessageGeneralForumTopicHidden),
GeneralForumTopicUnhidden(GeneralForumTopicUnhidden), GeneralForumTopicUnhidden(MessageGeneralForumTopicUnhidden),
VideoChatScheduled(MessageVideoChatScheduled), VideoChatScheduled(MessageVideoChatScheduled),
VideoChatStarted(MessageVideoChatStarted), VideoChatStarted(MessageVideoChatStarted),
VideoChatEnded(MessageVideoChatEnded), VideoChatEnded(MessageVideoChatEnded),
@ -523,12 +526,25 @@ pub struct MessageProximityAlertTriggered {
pub proximity_alert_triggered: ProximityAlertTriggered, pub proximity_alert_triggered: ProximityAlertTriggered,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageWriteAccessAllowed {
/// Service message: the user allowed the bot added to the attachment menu
/// to write messages.
pub write_access_allowed: WriteAccessAllowed,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageForumTopicCreated { pub struct MessageForumTopicCreated {
/// Service message: forum topic created. /// Service message: forum topic created.
pub forum_topic_created: ForumTopicCreated, pub forum_topic_created: ForumTopicCreated,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageForumTopicEdited {
/// Service message: forum topic edited.
pub forum_topic_edited: ForumTopicEdited,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageForumTopicClosed { pub struct MessageForumTopicClosed {
/// Service message: forum topic closed. /// Service message: forum topic closed.
@ -541,6 +557,18 @@ pub struct MessageForumTopicReopened {
pub forum_topic_reopened: ForumTopicReopened, pub forum_topic_reopened: ForumTopicReopened,
} }
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageGeneralForumTopicHidden {
/// Service message: the 'General' forum topic hidden.
pub general_forum_topic_hidden: GeneralForumTopicHidden,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageGeneralForumTopicUnhidden {
/// Service message: the 'General' forum topic unhidden.
pub general_forum_topic_unhidden: GeneralForumTopicUnhidden,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MessageVideoChatScheduled { pub struct MessageVideoChatScheduled {
/// Service message: video chat scheduled /// Service message: video chat scheduled