Skip to content
1 change: 1 addition & 0 deletions twilight-cache-inmemory/src/event/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ mod tests {
message: None,
token: "token".into(),
user: None,
attachment_size_limit: 0,
}));

{
Expand Down
17 changes: 16 additions & 1 deletion twilight-model/src/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ pub struct Interaction {
/// Present when the interaction is invoked in a direct message.
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<User>,
/// Attachment size limit in bytes
pub attachment_size_limit: u64,
}

impl Interaction {
Expand Down Expand Up @@ -208,6 +210,7 @@ enum InteractionField {
User,
Version,
AuthorizingIntegrationOwners,
AttachmentSizeLimit,
}

struct InteractionVisitor;
Expand Down Expand Up @@ -241,6 +244,7 @@ impl<'de> Visitor<'de> for InteractionVisitor {
let mut authorizing_integration_owners: Option<
ApplicationIntegrationMap<AnonymizableId<GuildMarker>, Id<UserMarker>>,
> = None;
let mut attachment_size_limit: Option<u64> = None;

loop {
let key = match map.next_key() {
Expand Down Expand Up @@ -384,6 +388,13 @@ impl<'de> Visitor<'de> for InteractionVisitor {

authorizing_integration_owners = map.next_value()?;
}
InteractionField::AttachmentSizeLimit => {
if attachment_size_limit.is_some() {
return Err(DeError::duplicate_field("attachment_size_limit"));
}

attachment_size_limit = map.next_value()?;
}
}
}

Expand Down Expand Up @@ -452,6 +463,7 @@ impl<'de> Visitor<'de> for InteractionVisitor {
message,
token,
user,
attachment_size_limit: attachment_size_limit.unwrap_or(0),
})
}
}
Expand Down Expand Up @@ -682,6 +694,7 @@ mod tests {
message: None,
token: "interaction token".into(),
user: None,
attachment_size_limit: 8_388_608,
};

// TODO: switch the `assert_tokens` see #2190
Expand All @@ -690,7 +703,7 @@ mod tests {
&[
Token::Struct {
name: "Interaction",
len: 14,
len: 15,
},
Token::Str("app_permissions"),
Token::Some,
Expand Down Expand Up @@ -914,6 +927,8 @@ mod tests {
Token::StructEnd,
Token::Str("token"),
Token::Str("interaction token"),
Token::Str("attachment_size_limit"),
Token::U64(8_388_608),
Token::StructEnd,
],
);
Expand Down
Loading