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

Remove patch left in for current to stay non-breaking #2732

Merged
merged 1 commit into from
Jan 22, 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
2 changes: 0 additions & 2 deletions src/model/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub struct BotGateway {
#[non_exhaustive]
pub struct Activity {
/// The ID of the application for the activity.
#[serde(deserialize_with = "deserialize_buggy_id")]
#[serde(default)]
pub application_id: Option<ApplicationId>,
/// Images for the presence and their texts.
pub assets: Option<ActivityAssets>,
Expand Down
24 changes: 0 additions & 24 deletions src/model/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,6 @@ where
remove_from_map_opt(map, key)?.ok_or_else(|| serde::de::Error::missing_field(key))
}

/// Workaround for Discord sending 0 value Ids as default values.
/// This has been fixed properly on next by swapping to a NonMax based impl.
pub fn deserialize_buggy_id<'de, D, Id>(deserializer: D) -> StdResult<Option<Id>, D::Error>
where
D: Deserializer<'de>,
Id: From<u64>,
{
#[derive(serde::Deserialize)]
#[serde(untagged)]
enum StringOrInt {
String(String),
Int(u64),
}

let raw = Option::<StringOrInt>::deserialize(deserializer)?;
let raw_int = match raw {
Some(StringOrInt::String(str)) => str.parse().map_err(serde::de::Error::custom)?,
Some(StringOrInt::Int(val)) => val,
None => return Ok(None),
};

Ok(Some(Id::from(raw_int)))
}

/// Used with `#[serde(with = "emojis")]`
pub mod emojis {
use std::collections::HashMap;
Expand Down