diff --git a/ruma-client-api/src/r0/message/get_message_events.rs b/ruma-client-api/src/r0/message/get_message_events.rs index 59e0407a..c2a536ac 100644 --- a/ruma-client-api/src/r0/message/get_message_events.rs +++ b/ruma-client-api/src/r0/message/get_message_events.rs @@ -47,9 +47,9 @@ ruma_api! { /// The maximum number of events to return. /// /// Default: 10. - #[serde(skip_serializing_if = "Option::is_none")] #[ruma_api(query)] - pub limit: Option, + #[serde(default = "default_limit", skip_serializing_if = "is_default_limit")] + pub limit: UInt, /// A RoomEventFilter to filter returned events with. #[ruma_api(query)] @@ -82,6 +82,15 @@ ruma_api! { error: crate::Error } +fn default_limit() -> UInt { + UInt::from(10u32) +} + +#[allow(clippy::trivially_copy_pass_by_ref)] +fn is_default_limit(val: &UInt) -> bool { + *val == default_limit() +} + /// The direction to return events from. #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub enum Direction { @@ -120,7 +129,7 @@ mod tests { from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, - limit: Some(UInt::from(0u32)), + limit: UInt::from(0u32), filter: Some(filter), }; @@ -139,7 +148,7 @@ mod tests { from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, - limit: Some(UInt::from(0u32)), + limit: UInt::from(0u32), filter: None, }; @@ -155,7 +164,7 @@ mod tests { from: "token".into(), to: Some("token2".into()), dir: Direction::Backward, - limit: Some(UInt::from(0u32)), + limit: UInt::from(0u32), filter: Some(RoomEventFilter::default()), }; diff --git a/ruma-events/CHANGELOG.md b/ruma-events/CHANGELOG.md index 9fbf17dc..8cf86ae6 100644 --- a/ruma-events/CHANGELOG.md +++ b/ruma-events/CHANGELOG.md @@ -2,6 +2,7 @@ Breaking changes: +* Change `get_message_events` limit field type from `Option` to `UInt` * Add `alt_aliases` to `CanonicalAliasEventContent` * Replace `format` and `formatted_body` fields in `TextMessagEventContent`, `NoticeMessageEventContent` and `EmoteMessageEventContent` with `formatted: FormattedBody`