From d0607b64597c4634a7423138e22eb6a9ee4a9973 Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Sat, 15 Mar 2025 00:29:52 +0000 Subject: [PATCH 1/2] chore(ruma): bump --- Cargo.lock | 22 +++++++++---------- Cargo.toml | 1 - src/service/rooms/event_handler/mod.rs | 30 +++++++++----------------- src/service/rooms/helpers/mod.rs | 1 - src/service/rooms/timeline/mod.rs | 9 +++----- 5 files changed, 24 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1671aa08..5895889b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2190,7 +2190,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.12.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "assign", "js_int", @@ -2209,7 +2209,7 @@ dependencies = [ [[package]] name = "ruma-appservice-api" version = "0.12.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "js_int", "ruma-common", @@ -2221,7 +2221,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.20.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "as_variant", "assign", @@ -2244,7 +2244,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.15.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "as_variant", "base64 0.22.1", @@ -2275,7 +2275,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.30.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "as_variant", "indexmap 2.2.6", @@ -2298,7 +2298,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.11.0" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "bytes", "headers", @@ -2320,7 +2320,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.10.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "js_int", "thiserror 2.0.11", @@ -2329,7 +2329,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.15.1" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "cfg-if", "proc-macro-crate", @@ -2344,7 +2344,7 @@ dependencies = [ [[package]] name = "ruma-push-gateway-api" version = "0.11.0" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "js_int", "ruma-common", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.17.0" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "base64 0.22.1", "ed25519-dalek", @@ -2372,7 +2372,7 @@ dependencies = [ [[package]] name = "ruma-state-res" version = "0.13.0" -source = "git+https://github.com/ruma/ruma.git#7c03b554c0d3e8b0a27fc0fadba36a4d636935d3" +source = "git+https://github.com/ruma/ruma.git#16185ab7fb1e054e8c37d8bf381d1e178dda0747" dependencies = [ "js_int", "ruma-common", diff --git a/Cargo.toml b/Cargo.toml index 345fba60..407a5e5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -153,7 +153,6 @@ features = [ "compat-optional", "compat-optional-txn-pdus", "compat-server-signing-key-version", - "compat-signature-id", "compat-tag-info", "compat-unset-avatar", "federation-api", diff --git a/src/service/rooms/event_handler/mod.rs b/src/service/rooms/event_handler/mod.rs index 0dd405c7..cc712b9a 100644 --- a/src/service/rooms/event_handler/mod.rs +++ b/src/service/rooms/event_handler/mod.rs @@ -483,12 +483,9 @@ impl Service { )); } - if !state_res::event_auth::auth_check( - &room_version, - &incoming_pdu, - None::, // TODO: third party invite - |k, s| auth_events.get(&(k.to_string().into(), s.to_owned())), - ) + if !state_res::event_auth::auth_check(&room_version, &incoming_pdu, |k, s| { + auth_events.get(&(k.to_string().into(), s.to_owned())) + }) .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed"))? { return Err(Error::BadRequest( @@ -792,11 +789,8 @@ impl Service { debug!("Starting auth check"); // 11. Check the auth of the event passes based on the state of the event - let check_result = state_res::event_auth::auth_check( - &room_version, - &incoming_pdu, - None::, // TODO: third party invite - |k, s| { + let check_result = + state_res::event_auth::auth_check(&room_version, &incoming_pdu, |k, s| { services() .rooms .short @@ -805,9 +799,8 @@ impl Service { .flatten() .and_then(|shortstatekey| state_at_incoming_event.get(&shortstatekey)) .and_then(|event_id| services().rooms.timeline.get_pdu(event_id).ok().flatten()) - }, - ) - .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))?; + }) + .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))?; if !check_result { return Err(Error::bad_database( @@ -825,12 +818,9 @@ impl Service { &incoming_pdu.content, )?; - let soft_fail = !state_res::event_auth::auth_check( - &room_version, - &incoming_pdu, - None::, - |k, s| auth_events.get(&(k.clone(), s.to_owned())), - ) + let soft_fail = !state_res::event_auth::auth_check(&room_version, &incoming_pdu, |k, s| { + auth_events.get(&(k.clone(), s.to_owned())) + }) .map_err(|_e| Error::BadRequest(ErrorKind::InvalidParam, "Auth check failed."))? || incoming_pdu.kind == TimelineEventType::RoomRedaction && match room_version_id { diff --git a/src/service/rooms/helpers/mod.rs b/src/service/rooms/helpers/mod.rs index e8d5b68a..24b5103a 100644 --- a/src/service/rooms/helpers/mod.rs +++ b/src/service/rooms/helpers/mod.rs @@ -233,7 +233,6 @@ impl Service { let authenticated = state_res::event_auth::auth_check( &state_res::RoomVersion::new(&room_version_id).expect("room version is supported"), &parsed_join_pdu, - None::, // TODO: third party invite |k, s| { services() .rooms diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 7615aed1..73966f24 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -766,12 +766,9 @@ impl Service { signatures: None, }; - let auth_check = state_res::auth_check( - &room_version, - &pdu, - None::, // TODO: third_party_invite - |k, s| auth_events.get(&(k.clone(), s.to_owned())), - ) + let auth_check = state_res::auth_check(&room_version, &pdu, |k, s| { + auth_events.get(&(k.clone(), s.to_owned())) + }) .map_err(|e| { error!("{:?}", e); Error::bad_database("Auth check failed.") From 0d8a4f4d102d5a8a307805625455a16a1736a0f3 Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Sat, 15 Mar 2025 00:31:47 +0000 Subject: [PATCH 2/2] switch to env var for enabling ruma exhaustive types this is more reliable than rustflags, since if RUST_FLAGS is set, then this setting would be ignored --- .cargo/config.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 1089e6cd..4c64d1c8 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ -[build] -rustflags = ["--cfg=ruma_unstable_exhaustive_types"] +[env] +RUMA_UNSTABLE_EXHAUSTIVE_TYPES = "1"