syncv3: use RoomTypeFilter struct instead of Option<RoomType>

Signed-off-by: morguldir <morguldir@protonmail.com>
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
morguldir 2024-09-07 18:09:21 +02:00
parent 593d3bb321
commit 3e0d404fb4
No known key found for this signature in database
GPG key ID: 5A6025D4F6E7A8A3
3 changed files with 31 additions and 39 deletions

27
Cargo.lock generated
View file

@ -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",

View file

@ -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

View file

@ -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<crate::State>, filter: &[Option<RoomType>], negate: bool,
rooms: &[OwnedRoomId], State(services): State<crate::State>, filter: &[RoomTypeFilter], negate: bool,
) -> Vec<OwnedRoomId> {
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();