From 3e0d404fb4b6b1506824f8d5dfeea7672dea3448 Mon Sep 17 00:00:00 2001 From: morguldir Date: Sat, 7 Sep 2024 18:09:21 +0200 Subject: [PATCH] syncv3: use RoomTypeFilter struct instead of Option Signed-off-by: morguldir Signed-off-by: strawberry --- Cargo.lock | 27 ++++++++++++++------------- Cargo.toml | 4 ++-- src/api/client/sync.rs | 39 +++++++++++++++------------------------ 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a75e6fd..539a9a2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2975,7 +2975,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.10.1" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "assign", "js_int", @@ -2997,7 +2997,7 @@ dependencies = [ [[package]] name = "ruma-appservice-api" version = "0.10.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "js_int", "ruma-common", @@ -3009,7 +3009,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.18.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "as_variant", "assign", @@ -3032,7 +3032,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.13.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "as_variant", "base64 0.22.1", @@ -3062,7 +3062,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.28.1" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "as_variant", "indexmap 2.4.0", @@ -3086,7 +3086,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.9.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "bytes", "http", @@ -3104,7 +3104,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.9.5" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "js_int", "thiserror", @@ -3113,7 +3113,7 @@ dependencies = [ [[package]] name = "ruma-identity-service-api" version = "0.9.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "js_int", "ruma-common", @@ -3123,8 +3123,9 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.13.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ + "cfg-if", "once_cell", "proc-macro-crate", "proc-macro2", @@ -3138,7 +3139,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.9.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "js_int", "ruma-common", @@ -3150,7 +3151,7 @@ dependencies = [ [[package]] name = "ruma-server-util" version = "0.3.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "headers", "http", @@ -3163,7 +3164,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.15.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "base64 0.22.1", "ed25519-dalek", @@ -3179,7 +3180,7 @@ dependencies = [ [[package]] name = "ruma-state-res" version = "0.11.0" -source = "git+https://github.com/girlbossceo/ruwuma?rev=83a9bf73668aa459ffcf5ca6f95639835c0bac79#83a9bf73668aa459ffcf5ca6f95639835c0bac79" +source = "git+https://github.com/girlbossceo/ruwuma?rev=11155e576a1382783c0bcf5ad4458708777ec36e#11155e576a1382783c0bcf5ad4458708777ec36e" dependencies = [ "itertools 0.12.1", "js_int", diff --git a/Cargo.toml b/Cargo.toml index b6cc257c..3419983a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -314,7 +314,7 @@ version = "0.1.2" [workspace.dependencies.ruma] git = "https://github.com/girlbossceo/ruwuma" #branch = "conduwuit-changes" -rev = "83a9bf73668aa459ffcf5ca6f95639835c0bac79" +rev = "11155e576a1382783c0bcf5ad4458708777ec36e" features = [ "compat", "rand", @@ -608,7 +608,7 @@ inherits = "release" # and can be raised if build times are tolerable. [profile.dev] -debug = 1 +debug = "full" opt-level = 0 panic = "unwind" debug-assertions = true diff --git a/src/api/client/sync.rs b/src/api/client/sync.rs index 4d080758..eb534205 100644 --- a/src/api/client/sync.rs +++ b/src/api/client/sync.rs @@ -25,12 +25,12 @@ use ruma::{ }, uiaa::UiaaResponse, }, + directory::RoomTypeFilter, events::{ presence::PresenceEvent, room::member::{MembershipState, RoomMemberEventContent}, AnyRawAccountDataEvent, StateEventType, TimelineEventType, }, - room::RoomType, serde::Raw, state_res::Event, uint, DeviceId, EventId, MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedUserId, RoomId, UInt, UserId, @@ -1760,32 +1760,23 @@ pub(crate) async fn sync_events_v4_route( } fn filter_rooms( - rooms: &[OwnedRoomId], State(services): State, filter: &[Option], negate: bool, + rooms: &[OwnedRoomId], State(services): State, filter: &[RoomTypeFilter], negate: bool, ) -> Vec { return rooms .iter() - .filter(|r| { - match services.rooms.state_accessor.get_room_type(r) { - Err(e) => { - warn!("Requested room type for {}, but could not retrieve with error {}", r, e); - false - }, - Ok(None) => { - // For rooms which do not have a room type, use 'null' to include them - if negate { - !filter.contains(&None) - } else { - filter.contains(&None) - } - }, - Ok(Some(room_type)) => { - if negate { - !filter.contains(&Some(room_type)) - } else { - filter.is_empty() || filter.contains(&Some(room_type)) - } - }, - } + .filter(|r| match services.rooms.state_accessor.get_room_type(r) { + Err(e) => { + warn!("Requested room type for {}, but could not retrieve with error {}", r, e); + false + }, + Ok(result) => { + let result = RoomTypeFilter::from(result); + if negate { + !filter.contains(&result) + } else { + filter.is_empty() || filter.contains(&result) + } + }, }) .cloned() .collect();