From a091faa7d27585db007045eef205efe119700fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 30 Sep 2022 15:29:30 +0200 Subject: [PATCH] client-api: Remove thread event filters According to MSC3856 --- crates/ruma-client-api/CHANGELOG.md | 2 ++ crates/ruma-client-api/Cargo.toml | 1 - crates/ruma-client-api/src/filter.rs | 53 +++------------------------- crates/ruma/Cargo.toml | 5 +-- 4 files changed, 7 insertions(+), 54 deletions(-) diff --git a/crates/ruma-client-api/CHANGELOG.md b/crates/ruma-client-api/CHANGELOG.md index be76df0f..52c9024f 100644 --- a/crates/ruma-client-api/CHANGELOG.md +++ b/crates/ruma-client-api/CHANGELOG.md @@ -8,6 +8,8 @@ Breaking changes: Improvements: * Add `M_BAD_ALIAS` to `error::ErrorKind` +* Remove the `unstable-msc3440` feature + * The fields added to `RoomEventFilter` were removed by MSC3856 # 0.15.1 diff --git a/crates/ruma-client-api/Cargo.toml b/crates/ruma-client-api/Cargo.toml index d2272355..64026a59 100644 --- a/crates/ruma-client-api/Cargo.toml +++ b/crates/ruma-client-api/Cargo.toml @@ -27,7 +27,6 @@ unstable-msc2676 = [] unstable-msc2677 = [] unstable-msc2965 = [] unstable-msc2967 = [] -unstable-msc3440 = [] unstable-msc3488 = [] unstable-msc3575 = [] client = [] diff --git a/crates/ruma-client-api/src/filter.rs b/crates/ruma-client-api/src/filter.rs index 1e2a2f67..c01a244d 100644 --- a/crates/ruma-client-api/src/filter.rs +++ b/crates/ruma-client-api/src/filter.rs @@ -7,8 +7,6 @@ mod lazy_load; mod url; use js_int::UInt; -#[cfg(feature = "unstable-msc3440")] -use ruma_common::events::relation::RelationType; use ruma_common::{ serde::{Incoming, StringEnum}, OwnedRoomId, OwnedUserId, @@ -99,32 +97,6 @@ pub struct RoomEventFilter<'a> { /// Defaults to `LazyLoadOptions::Disabled`. #[serde(flatten)] 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> { @@ -142,7 +114,7 @@ impl<'a> RoomEventFilter<'a> { /// Returns `true` if all fields are empty. pub fn is_empty(&self) -> bool { - let empty = self.not_types.is_empty() + self.not_types.is_empty() && self.not_rooms.is_empty() && self.limit.is_none() && self.rooms.is_none() @@ -150,20 +122,14 @@ impl<'a> RoomEventFilter<'a> { && self.senders.is_none() && self.types.is_none() && self.url_filter.is_none() - && 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(); + && self.lazy_load_options.is_disabled() } } impl IncomingRoomEventFilter { /// Returns `true` if all fields are empty. pub fn is_empty(&self) -> bool { - let empty = self.not_types.is_empty() + self.not_types.is_empty() && self.not_rooms.is_empty() && self.limit.is_none() && self.rooms.is_none() @@ -171,13 +137,7 @@ impl IncomingRoomEventFilter { && self.senders.is_none() && self.types.is_none() && self.url_filter.is_none() - && 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(); + && self.lazy_load_options.is_disabled() } } @@ -498,10 +458,5 @@ mod tests { filter.lazy_load_options, 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]); } } diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index 7f1ec919..244f69d3 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -145,10 +145,7 @@ unstable-msc2967 = ["ruma-client-api?/unstable-msc2967"] unstable-msc3245 = ["ruma-common/unstable-msc3245"] unstable-msc3246 = ["ruma-common/unstable-msc3246"] unstable-msc3381 = ["ruma-common/unstable-msc3381"] -unstable-msc3440 = [ - "ruma-client-api?/unstable-msc3440", - "ruma-common/unstable-msc3440", -] +unstable-msc3440 = ["ruma-common/unstable-msc3440"] unstable-msc3488 = [ "ruma-client-api?/unstable-msc3488", "ruma-common/unstable-msc3488",