Skip to content

Commit

Permalink
make timeout and ban reason None if empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilgardis committed Feb 22, 2025
1 parent a930d64 commit 875753c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

[Commits](https://github.com/twitch-rs/twitch_api/compare/v0.7.0...Unreleased)

### Fixed

- Eventsub `channel.moderate` action `Timeout` and `Ban` field `reason` is now `None` when the string is empty.

## [v0.7.0] - 2025-01-22

[Commits](https://github.com/twitch-rs/twitch_api/compare/v0.6.1...v0.7.0)
Expand Down
12 changes: 12 additions & 0 deletions src/eventsub/channel/moderate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ pub struct Ban {
/// The user name of the user being banned.
pub user_name: types::DisplayName,
/// Reason given for the ban.
#[serde(
default,
deserialize_with = "crate::deserialize_none_from_empty_string"
)]
pub reason: Option<String>,
}

Expand Down Expand Up @@ -307,6 +311,10 @@ pub struct Timeout {
/// The user name of the user being timed out.
pub user_name: types::DisplayName,
/// The reason given for the timeout.
#[serde(
default,
deserialize_with = "crate::deserialize_none_from_empty_string"
)]
pub reason: Option<String>,
/// The time at which the timeout ends.
pub expires_at: types::Timestamp,
Expand Down Expand Up @@ -870,6 +878,10 @@ pub struct Warn {
/// The user name of the user being warned.
pub user_name: types::DisplayName,
/// Reason given for the warning.
#[serde(
default,
deserialize_with = "crate::deserialize_none_from_empty_string"
)]
pub reason: Option<String>,
/// Chat rules cited for the warning.
pub chat_rules_cited: Option<Vec<String>>,
Expand Down

0 comments on commit 875753c

Please sign in to comment.