push-gateway-api: Remove PartialEq impl for NotificationCounts

This commit is contained in:
Jonas Platte 2022-05-23 18:29:08 +02:00
parent 0a47a2d915
commit b4f69549f8
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
2 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# [unreleased] # [unreleased]
Breaking changes:
* Remove `PartialEq` implementation for `NotificationCounts`
# 0.5.0 # 0.5.0
Breaking changes: Breaking changes:

View File

@ -8,7 +8,7 @@ pub mod v1 {
//! //!
//! [spec]: https://spec.matrix.org/v1.2/push-gateway-api/#post_matrixpushv1notify //! [spec]: https://spec.matrix.org/v1.2/push-gateway-api/#post_matrixpushv1notify
use js_int::UInt; use js_int::{uint, UInt};
use ruma_common::{ use ruma_common::{
api::ruma_api, api::ruma_api,
events::RoomEventType, events::RoomEventType,
@ -126,7 +126,7 @@ pub mod v1 {
/// Current number of unacknowledged communications for the recipient user. /// Current number of unacknowledged communications for the recipient user.
/// ///
/// Counts whose value is zero should be omitted. /// 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, pub counts: NotificationCounts,
/// An array of devices that the notification should be sent to. /// 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. /// 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)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct NotificationCounts { pub struct NotificationCounts {
/// The number of unread messages a user has across all of the rooms they /// 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 { pub fn new(unread: UInt, missed_calls: UInt) -> Self {
NotificationCounts { unread, missed_calls } NotificationCounts { unread, missed_calls }
} }
fn is_default(&self) -> bool {
self.unread == uint!(0) && self.missed_calls == uint!(0)
}
} }
/// Type for passing information about devices. /// Type for passing information about devices.