From b4f69549f874791f1f08f4f0f199e6d758b33233 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 23 May 2022 18:29:08 +0200 Subject: [PATCH] push-gateway-api: Remove PartialEq impl for NotificationCounts --- crates/ruma-push-gateway-api/CHANGELOG.md | 4 ++++ .../src/send_event_notification.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/ruma-push-gateway-api/CHANGELOG.md b/crates/ruma-push-gateway-api/CHANGELOG.md index bcc4a770..011b0674 100644 --- a/crates/ruma-push-gateway-api/CHANGELOG.md +++ b/crates/ruma-push-gateway-api/CHANGELOG.md @@ -1,5 +1,9 @@ # [unreleased] +Breaking changes: + +* Remove `PartialEq` implementation for `NotificationCounts` + # 0.5.0 Breaking changes: diff --git a/crates/ruma-push-gateway-api/src/send_event_notification.rs b/crates/ruma-push-gateway-api/src/send_event_notification.rs index ff737281..430a7766 100644 --- a/crates/ruma-push-gateway-api/src/send_event_notification.rs +++ b/crates/ruma-push-gateway-api/src/send_event_notification.rs @@ -8,7 +8,7 @@ pub mod v1 { //! //! [spec]: https://spec.matrix.org/v1.2/push-gateway-api/#post_matrixpushv1notify - use js_int::UInt; + use js_int::{uint, UInt}; use ruma_common::{ api::ruma_api, events::RoomEventType, @@ -126,7 +126,7 @@ pub mod v1 { /// Current number of unacknowledged communications for the recipient user. /// /// Counts whose value is zero should be omitted. - #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] + #[serde(default, skip_serializing_if = "NotificationCounts::is_default")] pub counts: NotificationCounts, /// An array of devices that the notification should be sent to. @@ -176,7 +176,7 @@ pub mod v1 { } /// Type for passing information about notification counts. - #[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)] + #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] pub struct NotificationCounts { /// The number of unread messages a user has across all of the rooms they @@ -196,6 +196,10 @@ pub mod v1 { pub fn new(unread: UInt, missed_calls: UInt) -> Self { NotificationCounts { unread, missed_calls } } + + fn is_default(&self) -> bool { + self.unread == uint!(0) && self.missed_calls == uint!(0) + } } /// Type for passing information about devices.