client-api: Remove thread event filters

According to MSC3856
This commit is contained in:
Kévin Commaille 2022-09-30 15:29:30 +02:00 committed by Kévin Commaille
parent 106527ec7e
commit a091faa7d2
4 changed files with 7 additions and 54 deletions

View File

@ -8,6 +8,8 @@ Breaking changes:
Improvements: Improvements:
* Add `M_BAD_ALIAS` to `error::ErrorKind` * Add `M_BAD_ALIAS` to `error::ErrorKind`
* Remove the `unstable-msc3440` feature
* The fields added to `RoomEventFilter` were removed by MSC3856
# 0.15.1 # 0.15.1

View File

@ -27,7 +27,6 @@ unstable-msc2676 = []
unstable-msc2677 = [] unstable-msc2677 = []
unstable-msc2965 = [] unstable-msc2965 = []
unstable-msc2967 = [] unstable-msc2967 = []
unstable-msc3440 = []
unstable-msc3488 = [] unstable-msc3488 = []
unstable-msc3575 = [] unstable-msc3575 = []
client = [] client = []

View File

@ -7,8 +7,6 @@ mod lazy_load;
mod url; mod url;
use js_int::UInt; use js_int::UInt;
#[cfg(feature = "unstable-msc3440")]
use ruma_common::events::relation::RelationType;
use ruma_common::{ use ruma_common::{
serde::{Incoming, StringEnum}, serde::{Incoming, StringEnum},
OwnedRoomId, OwnedUserId, OwnedRoomId, OwnedUserId,
@ -99,32 +97,6 @@ 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,
/// A list of relation types to include.
///
/// An event A is included in the filter only if there exists another event B which relates to
/// A with a `rel_type` which is defined in the list.
#[cfg(feature = "unstable-msc3440")]
#[serde(
rename = "io.element.relation_types",
alias = "related_by_rel_types",
default,
skip_serializing_if = "<[_]>::is_empty"
)]
pub related_by_rel_types: &'a [RelationType],
/// A list of senders to include.
///
/// An event A is included in the filter only if there exists another event B which relates to
/// A, and which has a sender which is in the list.
#[cfg(feature = "unstable-msc3440")]
#[serde(
rename = "io.element.relation_senders",
alias = "related_by_senders",
default,
skip_serializing_if = "<[_]>::is_empty"
)]
pub related_by_senders: &'a [OwnedUserId],
} }
impl<'a> RoomEventFilter<'a> { impl<'a> RoomEventFilter<'a> {
@ -142,7 +114,7 @@ impl<'a> RoomEventFilter<'a> {
/// Returns `true` if all fields are empty. /// Returns `true` if all fields are empty.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
let empty = self.not_types.is_empty() self.not_types.is_empty()
&& self.not_rooms.is_empty() && self.not_rooms.is_empty()
&& self.limit.is_none() && self.limit.is_none()
&& self.rooms.is_none() && self.rooms.is_none()
@ -150,20 +122,14 @@ impl<'a> RoomEventFilter<'a> {
&& self.senders.is_none() && self.senders.is_none()
&& 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()
#[cfg(not(feature = "unstable-msc3440"))]
return empty;
#[cfg(feature = "unstable-msc3440")]
return empty && self.related_by_rel_types.is_empty() && self.related_by_senders.is_empty();
} }
} }
impl IncomingRoomEventFilter { impl IncomingRoomEventFilter {
/// Returns `true` if all fields are empty. /// Returns `true` if all fields are empty.
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
let empty = self.not_types.is_empty() self.not_types.is_empty()
&& self.not_rooms.is_empty() && self.not_rooms.is_empty()
&& self.limit.is_none() && self.limit.is_none()
&& self.rooms.is_none() && self.rooms.is_none()
@ -171,13 +137,7 @@ impl IncomingRoomEventFilter {
&& self.senders.is_none() && self.senders.is_none()
&& 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()
#[cfg(not(feature = "unstable-msc3440"))]
return empty;
#[cfg(feature = "unstable-msc3440")]
return empty && self.related_by_rel_types.is_empty() && self.related_by_senders.is_empty();
} }
} }
@ -498,10 +458,5 @@ mod tests {
filter.lazy_load_options, filter.lazy_load_options,
LazyLoadOptions::Enabled { include_redundant_members: false } LazyLoadOptions::Enabled { include_redundant_members: false }
); );
#[cfg(feature = "unstable-msc3440")]
assert_eq!(filter.related_by_rel_types, vec![]);
#[cfg(feature = "unstable-msc3440")]
assert_eq!(filter.related_by_senders, vec![""; 0]);
} }
} }

View File

@ -145,10 +145,7 @@ unstable-msc2967 = ["ruma-client-api?/unstable-msc2967"]
unstable-msc3245 = ["ruma-common/unstable-msc3245"] unstable-msc3245 = ["ruma-common/unstable-msc3245"]
unstable-msc3246 = ["ruma-common/unstable-msc3246"] unstable-msc3246 = ["ruma-common/unstable-msc3246"]
unstable-msc3381 = ["ruma-common/unstable-msc3381"] unstable-msc3381 = ["ruma-common/unstable-msc3381"]
unstable-msc3440 = [ unstable-msc3440 = ["ruma-common/unstable-msc3440"]
"ruma-client-api?/unstable-msc3440",
"ruma-common/unstable-msc3440",
]
unstable-msc3488 = [ unstable-msc3488 = [
"ruma-client-api?/unstable-msc3488", "ruma-client-api?/unstable-msc3488",
"ruma-common/unstable-msc3488", "ruma-common/unstable-msc3488",