diff --git a/src/r0/keys/claim_keys.rs b/src/r0/keys/claim_keys.rs index 0275fd1b..3b4dd450 100644 --- a/src/r0/keys/claim_keys.rs +++ b/src/r0/keys/claim_keys.rs @@ -23,8 +23,11 @@ ruma_api! { request { /// The time (in milliseconds) to wait when downloading keys from remote servers. /// 10 seconds is the recommended default. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default, with = "crate::serde::duration::opt_ms")] + #[serde( + with = "crate::serde::duration::opt_ms", + default, + skip_serializing_if = "Option::is_none", + )] pub timeout: Option, /// The keys to be claimed. diff --git a/src/r0/keys/get_keys.rs b/src/r0/keys/get_keys.rs index b6049a39..98628261 100644 --- a/src/r0/keys/get_keys.rs +++ b/src/r0/keys/get_keys.rs @@ -21,8 +21,11 @@ ruma_api! { request { /// The time (in milliseconds) to wait when downloading keys from remote servers. /// 10 seconds is the recommended default. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default, with = "crate::serde::duration::opt_ms")] + #[serde( + with = "crate::serde::duration::opt_ms", + default, + skip_serializing_if = "Option::is_none", + )] pub timeout: Option, /// The keys to be downloaded. An empty list indicates all devices for the corresponding user. diff --git a/src/r0/presence/get_presence.rs b/src/r0/presence/get_presence.rs index 9e344566..6424435b 100644 --- a/src/r0/presence/get_presence.rs +++ b/src/r0/presence/get_presence.rs @@ -30,8 +30,11 @@ ruma_api! { #[serde(skip_serializing_if = "Option::is_none")] pub currently_active: Option, /// The length of time in milliseconds since an action was performed by the user. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default, with = "crate::serde::duration::opt_ms")] + #[serde( + with = "crate::serde::duration::opt_ms", + default, + skip_serializing_if = "Option::is_none", + )] pub last_active_ago: Option, /// The user's presence state. pub presence: PresenceState, diff --git a/src/r0/typing/create_typing_event.rs b/src/r0/typing/create_typing_event.rs index d24dc82c..3731ad02 100644 --- a/src/r0/typing/create_typing_event.rs +++ b/src/r0/typing/create_typing_event.rs @@ -20,8 +20,11 @@ ruma_api! { #[ruma_api(path)] pub room_id: RoomId, /// The length of time in milliseconds to mark this user as typing. - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default, with = "crate::serde::duration::opt_ms")] + #[serde( + with = "crate::serde::duration::opt_ms", + default, + skip_serializing_if = "Option::is_none", + )] pub timeout: Option, /// Whether the user is typing or not. If `false`, the `timeout` key can be omitted. pub typing: bool, diff --git a/src/serde/duration/opt_ms.rs b/src/serde/duration/opt_ms.rs index 9e304eda..0704324d 100644 --- a/src/serde/duration/opt_ms.rs +++ b/src/serde/duration/opt_ms.rs @@ -44,8 +44,11 @@ mod tests { #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] struct DurationTest { - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(default, with = "crate::serde::duration::opt_ms")] + #[serde( + with = "crate::serde::duration::opt_ms", + default, + skip_serializing_if = "Option::is_none" + )] timeout: Option, }