Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix serialization of InlineQueryResult #230

Merged
merged 10 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async-telegram-trait = ["dep:async-trait"]

[lints.rust]
unsafe_code = "forbid"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rust_analyzer)'] }
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Veetaha might interest this. There is also elastio/bon#212 which might be similar / related. 👀

Copy link
Contributor

@Veetaha Veetaha Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a regression on nightly only. It was worked around in a 3.0.2 version. I think you can upgrade to this version without a migration

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be its own PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there is a dependabot PR #229

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be its own PR?

To extend to that, this only fails on nightly so I would just ignore this for this PR and remove this change. A bon patch is there, and I could also see rust_analyzer being added to the list of well known values. So a change in this repo seems in the wrong place either way.

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
Expand Down
52 changes: 16 additions & 36 deletions src/api_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,48 +52,28 @@ impl From<String> for FileUpload {
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum InlineQueryResult {
#[serde(rename = "audio")]
CachedAudio(InlineQueryResultCachedAudio),
#[serde(rename = "document")]
CachedDocument(InlineQueryResultCachedDocument),
#[serde(rename = "gif")]
CachedGif(InlineQueryResultCachedGif),
#[serde(rename = "mpeg4_gif")]
CachedMpeg4Gif(InlineQueryResultCachedMpeg4Gif),
#[serde(rename = "photo")]
CachedPhoto(InlineQueryResultCachedPhoto),
#[serde(rename = "sticker")]
CachedSticker(InlineQueryResultCachedSticker),
#[serde(rename = "video")]
CachedVideo(InlineQueryResultCachedVideo),
#[serde(rename = "voice")]
CachedVoice(InlineQueryResultCachedVoice),
#[serde(rename = "article")]
Audio(MaybeCached<InlineQueryResultCachedAudio, InlineQueryResultAudio>),
Document(MaybeCached<InlineQueryResultCachedDocument, InlineQueryResultDocument>),
Gif(MaybeCached<InlineQueryResultCachedGif, InlineQueryResultGif>),
Mpeg4Gif(MaybeCached<InlineQueryResultCachedMpeg4Gif, InlineQueryResultMpeg4Gif>),
Photo(MaybeCached<InlineQueryResultCachedPhoto, InlineQueryResultPhoto>),
Sticker(InlineQueryResultCachedSticker),
Video(MaybeCached<InlineQueryResultCachedVideo, InlineQueryResultVideo>),
Voice(MaybeCached<InlineQueryResultCachedVoice, InlineQueryResultVoice>),
Article(InlineQueryResultArticle),
#[serde(rename = "audio")]
Audio(InlineQueryResultAudio),
#[serde(rename = "contract")]
Contact(InlineQueryResultContact),
#[serde(rename = "game")]
Game(InlineQueryResultGame),
#[serde(rename = "document")]
Document(InlineQueryResultDocument),
#[serde(rename = "gif")]
Gif(InlineQueryResultGif),
#[serde(rename = "location")]
Location(InlineQueryResultLocation),
#[serde(rename = "mpeg4_gif")]
Mpeg4Gif(InlineQueryResultMpeg4Gif),
#[serde(rename = "photo")]
Photo(InlineQueryResultPhoto),
#[serde(rename = "venue")]
Venue(InlineQueryResultVenue),
#[serde(rename = "video")]
Video(InlineQueryResultVideo),
#[serde(rename = "voice")]
Voice(InlineQueryResultVoice),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(untagged)]
pub enum MaybeCached<T1, T2> {
Cached(T1),
NotCached(T2),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
Expand Down