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(model): Entitlements would only deserialize it was before data #2359

Merged
merged 1 commit into from
Jul 13, 2024
Merged
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
6 changes: 4 additions & 2 deletions twilight-model/src/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'de> Visitor<'de> for InteractionVisitor {
let mut channel: Option<Channel> = None;
let mut channel_id: Option<Id<ChannelMarker>> = None;
let mut data: Option<Value> = None;
let mut entitlements: Vec<Entitlement> = Vec::new();
let mut entitlements: Option<Vec<Entitlement>> = None;
let mut guild_id: Option<Id<GuildMarker>> = None;
let mut guild_locale: Option<String> = None;
let mut id: Option<Id<InteractionMarker>> = None;
Expand Down Expand Up @@ -269,7 +269,7 @@ impl<'de> Visitor<'de> for InteractionVisitor {
data = map.next_value()?;
}
InteractionField::Entitlements => {
if data.is_some() {
if entitlements.is_some() {
return Err(DeError::duplicate_field("entitlements"));
}

Expand Down Expand Up @@ -387,6 +387,8 @@ impl<'de> Visitor<'de> for InteractionVisitor {
}
};

let entitlements = entitlements.unwrap_or_default();

Ok(Self::Value {
app_permissions,
application_id,
Expand Down