client-api: Add support for notifications for threads
According to MSC 3773
This commit is contained in:
parent
4debc88263
commit
b57338c1cf
@ -16,6 +16,7 @@ Improvements:
|
|||||||
* Add support for the threads list API (MSC3856 / Matrix 1.4)
|
* Add support for the threads list API (MSC3856 / Matrix 1.4)
|
||||||
* Stabilize support for private read receipts
|
* Stabilize support for private read receipts
|
||||||
* Add support for the pagination direction parameter to `/relations` (MSC3715 / Matrix 1.4)
|
* Add support for the pagination direction parameter to `/relations` (MSC3715 / Matrix 1.4)
|
||||||
|
* Add support for notifications for threads (MSC3773 / Matrix 1.4)
|
||||||
|
|
||||||
# 0.15.1
|
# 0.15.1
|
||||||
|
|
||||||
|
@ -97,6 +97,15 @@ pub struct RoomEventFilter<'a> {
|
|||||||
/// Defaults to `LazyLoadOptions::Disabled`.
|
/// Defaults to `LazyLoadOptions::Disabled`.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub lazy_load_options: LazyLoadOptions,
|
pub lazy_load_options: LazyLoadOptions,
|
||||||
|
|
||||||
|
/// Whether to enable [per-thread notification counts].
|
||||||
|
///
|
||||||
|
/// Only applies to the [`sync_events`] endpoint.
|
||||||
|
///
|
||||||
|
/// [per-thread notification counts]: https://spec.matrix.org/v1.4/client-server-api/#receiving-notifications
|
||||||
|
/// [`sync_events`]: crate::sync::sync_events
|
||||||
|
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
|
||||||
|
pub unread_thread_notifications: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> RoomEventFilter<'a> {
|
impl<'a> RoomEventFilter<'a> {
|
||||||
@ -123,6 +132,7 @@ impl<'a> RoomEventFilter<'a> {
|
|||||||
&& self.types.is_none()
|
&& self.types.is_none()
|
||||||
&& self.url_filter.is_none()
|
&& self.url_filter.is_none()
|
||||||
&& self.lazy_load_options.is_disabled()
|
&& self.lazy_load_options.is_disabled()
|
||||||
|
&& !self.unread_thread_notifications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +148,7 @@ impl IncomingRoomEventFilter {
|
|||||||
&& self.types.is_none()
|
&& self.types.is_none()
|
||||||
&& self.url_filter.is_none()
|
&& self.url_filter.is_none()
|
||||||
&& self.lazy_load_options.is_disabled()
|
&& self.lazy_load_options.is_disabled()
|
||||||
|
&& !self.unread_thread_notifications
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ pub mod v4;
|
|||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[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 UnreadNotificationsCount {
|
pub struct UnreadNotificationsCount {
|
||||||
/// The number of unread notifications for this room with the highlight flag set.
|
/// The number of unread notifications with the highlight flag set.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub highlight_count: Option<UInt>,
|
pub highlight_count: Option<UInt>,
|
||||||
|
|
||||||
/// The total number of unread notifications for this room.
|
/// The total number of unread notifications.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub notification_count: Option<UInt>,
|
pub notification_count: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ use ruma_common::{
|
|||||||
},
|
},
|
||||||
presence::PresenceState,
|
presence::PresenceState,
|
||||||
serde::{Incoming, Raw},
|
serde::{Incoming, Raw},
|
||||||
DeviceKeyAlgorithm, OwnedRoomId,
|
DeviceKeyAlgorithm, OwnedEventId, OwnedRoomId,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -243,10 +243,27 @@ pub struct JoinedRoom {
|
|||||||
#[serde(default, skip_serializing_if = "RoomSummary::is_empty")]
|
#[serde(default, skip_serializing_if = "RoomSummary::is_empty")]
|
||||||
pub summary: RoomSummary,
|
pub summary: RoomSummary,
|
||||||
|
|
||||||
/// Counts of unread notifications for this room.
|
/// Counts of [unread notifications] for this room.
|
||||||
|
///
|
||||||
|
/// If `unread_thread_notifications` was set to `true` in the [`RoomEventFilter`], these
|
||||||
|
/// include only the unread notifications for the main timeline.
|
||||||
|
///
|
||||||
|
/// [unread notifications]: https://spec.matrix.org/v1.4/client-server-api/#receiving-notifications
|
||||||
|
/// [`RoomEventFilter`]: crate::filter::RoomEventFilter
|
||||||
#[serde(default, skip_serializing_if = "UnreadNotificationsCount::is_empty")]
|
#[serde(default, skip_serializing_if = "UnreadNotificationsCount::is_empty")]
|
||||||
pub unread_notifications: UnreadNotificationsCount,
|
pub unread_notifications: UnreadNotificationsCount,
|
||||||
|
|
||||||
|
/// Counts of [unread notifications] for threads in this room.
|
||||||
|
///
|
||||||
|
/// This is a map from thread root ID to unread notifications in the thread.
|
||||||
|
///
|
||||||
|
/// Only set if `unread_thread_notifications` was set to `true` in the [`RoomEventFilter`].
|
||||||
|
///
|
||||||
|
/// [unread notifications]: https://spec.matrix.org/v1.4/client-server-api/#receiving-notifications
|
||||||
|
/// [`RoomEventFilter`]: crate::filter::RoomEventFilter
|
||||||
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
|
pub unread_thread_notifications: BTreeMap<OwnedEventId, UnreadNotificationsCount>,
|
||||||
|
|
||||||
/// The timeline of messages and state changes in the room.
|
/// The timeline of messages and state changes in the room.
|
||||||
#[serde(default, skip_serializing_if = "Timeline::is_empty")]
|
#[serde(default, skip_serializing_if = "Timeline::is_empty")]
|
||||||
pub timeline: Timeline,
|
pub timeline: Timeline,
|
||||||
@ -290,6 +307,7 @@ impl JoinedRoom {
|
|||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
let is_empty = self.summary.is_empty()
|
let is_empty = self.summary.is_empty()
|
||||||
&& self.unread_notifications.is_empty()
|
&& self.unread_notifications.is_empty()
|
||||||
|
&& self.unread_thread_notifications.is_empty()
|
||||||
&& self.timeline.is_empty()
|
&& self.timeline.is_empty()
|
||||||
&& self.state.is_empty()
|
&& self.state.is_empty()
|
||||||
&& self.account_data.is_empty()
|
&& self.account_data.is_empty()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user