From 12b1102ca91b2e6dffab3c88aea97af299855010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 3 Mar 2026 19:00:59 +0100 Subject: [PATCH] Upgrade Ruma after breaking change about Reply relations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- Cargo.lock | 18 ++++++------ Cargo.toml | 2 +- bindings/matrix-sdk-ffi/src/event.rs | 2 +- .../src/timeline/controller/metadata.rs | 4 +-- .../tests/integration/timeline/replies.rs | 29 ++++++++++--------- crates/matrix-sdk/src/room/reply.rs | 4 +-- testing/matrix-sdk-test/src/event_factory.rs | 10 +++---- 7 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 90e9d0640..25ab57f49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4742,7 +4742,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.14.1" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "assign", "js_int", @@ -4760,7 +4760,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.22.1" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "as_variant", "assign", @@ -4783,7 +4783,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.17.1" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "as_variant", "base64", @@ -4816,7 +4816,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.32.1" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "as_variant", "indexmap", @@ -4843,7 +4843,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.13.1" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "headers", "http", @@ -4864,7 +4864,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.6.0" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "as_variant", "html5ever", @@ -4875,7 +4875,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.12.0" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "js_int", "thiserror 2.0.17", @@ -4884,7 +4884,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.17.1" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "as_variant", "cfg-if", @@ -4900,7 +4900,7 @@ dependencies = [ [[package]] name = "ruma-signatures" version = "0.19.0" -source = "git+https://github.com/ruma/ruma?rev=f144deacadb4967044d48d63c49e41db4e3282f0#f144deacadb4967044d48d63c49e41db4e3282f0" +source = "git+https://github.com/ruma/ruma?rev=1bd55759b8ee083736d239b357c97ec82d12bba1#1bd55759b8ee083736d239b357c97ec82d12bba1" dependencies = [ "base64", "ed25519-dalek", diff --git a/Cargo.toml b/Cargo.toml index ac5d9024c..2077da3d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ rand = { version = "0.8.5", default-features = false, features = ["std", "std_rn regex = { version = "1.12.2", default-features = false } reqwest = { version = "0.12.24", default-features = false } rmp-serde = { version = "1.3.0", default-features = false } -ruma = { git = "https://github.com/ruma/ruma", rev = "f144deacadb4967044d48d63c49e41db4e3282f0", features = [ +ruma = { git = "https://github.com/ruma/ruma", rev = "1bd55759b8ee083736d239b357c97ec82d12bba1", features = [ "client-api-c", "compat-unset-avatar", "compat-upload-signatures", diff --git a/bindings/matrix-sdk-ffi/src/event.rs b/bindings/matrix-sdk-ffi/src/event.rs index 817b6b317..6926445b9 100644 --- a/bindings/matrix-sdk-ffi/src/event.rs +++ b/bindings/matrix-sdk-ffi/src/event.rs @@ -472,7 +472,7 @@ impl TryFrom for MessageLikeEventContent { let original_content = get_message_like_event_original_content(content)?; let in_reply_to_event_id = original_content.relates_to.and_then(|relation| match relation { - Relation::Reply { in_reply_to } => Some(in_reply_to.event_id.to_string()), + Relation::Reply(reply) => Some(reply.in_reply_to.event_id.to_string()), _ => None, }); MessageLikeEventContent::RoomMessage { diff --git a/crates/matrix-sdk-ui/src/timeline/controller/metadata.rs b/crates/matrix-sdk-ui/src/timeline/controller/metadata.rs index e1918f34b..087a06164 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/metadata.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/metadata.rs @@ -462,8 +462,8 @@ impl TimelineMetadata { let mut thread_root = None; let in_reply_to = relates_to.and_then(|relation| match relation { - RelationWithoutReplacement::Reply { in_reply_to } => { - Some(InReplyToDetails::new(in_reply_to.event_id, timeline_items)) + RelationWithoutReplacement::Reply(reply) => { + Some(InReplyToDetails::new(reply.in_reply_to.event_id, timeline_items)) } RelationWithoutReplacement::Thread(thread) => { thread_root = Some(thread.event_id); diff --git a/crates/matrix-sdk-ui/tests/integration/timeline/replies.rs b/crates/matrix-sdk-ui/tests/integration/timeline/replies.rs index ef12637cf..c95bebd9d 100644 --- a/crates/matrix-sdk-ui/tests/integration/timeline/replies.rs +++ b/crates/matrix-sdk-ui/tests/integration/timeline/replies.rs @@ -18,7 +18,6 @@ use ruma::{ events::{ Mentions, reaction::RedactedReactionEventContent, - relation::InReplyTo, room::{ ImageInfo, encrypted::{ @@ -678,7 +677,8 @@ async fn test_send_reply() { assert_next_matches!(timeline_stream, VectorDiff::Clear); // Now, let's reply to a message sent by `BOB`. - server.mock_room_send() + server + .mock_room_send() .respond_with(move |req: &Request| { use ruma::events::room::message::RoomMessageEventContent; @@ -686,8 +686,8 @@ async fn test_send_reply() { .body_json::() .expect("Failed to deserialize the event"); - assert_matches!(reply_event.relates_to, Some(Relation::Reply { in_reply_to: InReplyTo { event_id, .. } }) => { - assert_eq!(event_id, event_id_from_bob); + assert_matches!(reply_event.relates_to, Some(Relation::Reply(reply)) => { + assert_eq!(reply.in_reply_to.event_id, event_id_from_bob); }); assert_matches!(reply_event.mentions, Some(Mentions { user_ids, room: false, .. }) => { assert_eq!(user_ids.len(), 1); @@ -780,7 +780,8 @@ async fn test_send_reply_to_self() { assert_next_matches!(timeline_stream, VectorDiff::Clear); // Now, let's reply to a message sent by the current user. - server.mock_room_send() + server + .mock_room_send() .respond_with(move |req: &Request| { use ruma::events::room::message::RoomMessageEventContent; @@ -788,8 +789,8 @@ async fn test_send_reply_to_self() { .body_json::() .expect("Failed to deserialize the event"); - assert_matches!(reply_event.relates_to, Some(Relation::Reply { in_reply_to: InReplyTo { event_id, .. } }) => { - assert_eq!(event_id, event_id_from_self); + assert_matches!(reply_event.relates_to, Some(Relation::Reply(reply)) => { + assert_eq!(reply.in_reply_to.event_id, event_id_from_self); }); assert!(reply_event.mentions.is_none()); @@ -944,7 +945,8 @@ async fn test_send_reply_with_event_id() { assert_next_matches!(timeline_stream, VectorDiff::Clear); // Now, let's reply to a message sent by `BOB`. - server.mock_room_send() + server + .mock_room_send() .respond_with(move |req: &Request| { use ruma::events::room::message::RoomMessageEventContent; @@ -952,8 +954,8 @@ async fn test_send_reply_with_event_id() { .body_json::() .expect("Failed to deserialize the event"); - assert_matches!(reply_event.relates_to, Some(Relation::Reply { in_reply_to: InReplyTo { event_id, .. } }) => { - assert_eq!(event_id, event_id_from_bob); + assert_matches!(reply_event.relates_to, Some(Relation::Reply(reply)) => { + assert_eq!(reply.in_reply_to.event_id, event_id_from_bob); }); assert_matches!(reply_event.mentions, Some(Mentions { user_ids, room: false, .. }) => { assert_eq!(user_ids.len(), 1); @@ -1230,7 +1232,8 @@ async fn test_send_reply_with_event_id_that_is_redacted() { assert_next_matches!(timeline_stream, VectorDiff::Clear); // Now, let's reply to a message sent by `BOB`. - server.mock_room_send() + server + .mock_room_send() .respond_with(move |req: &Request| { use ruma::events::room::message::RoomMessageEventContent; @@ -1238,8 +1241,8 @@ async fn test_send_reply_with_event_id_that_is_redacted() { .body_json::() .expect("Failed to deserialize the event"); - assert_matches!(reply_event.relates_to, Some(Relation::Reply { in_reply_to: InReplyTo { event_id, .. } }) => { - assert_eq!(event_id, redacted_event_id_from_bob); + assert_matches!(reply_event.relates_to, Some(Relation::Reply(reply)) => { + assert_eq!(reply.in_reply_to.event_id, redacted_event_id_from_bob); }); assert_matches!(reply_event.mentions, Some(Mentions { user_ids, room: false, .. }) => { assert_eq!(user_ids.len(), 1); diff --git a/crates/matrix-sdk/src/room/reply.rs b/crates/matrix-sdk/src/room/reply.rs index efa2d01cd..22558f3a3 100644 --- a/crates/matrix-sdk/src/room/reply.rs +++ b/crates/matrix-sdk/src/room/reply.rs @@ -295,9 +295,9 @@ mod tests { .await .unwrap(); - assert_let!(Some(Relation::Reply { in_reply_to }) = &reply_event.relates_to); + assert_let!(Some(Relation::Reply(reply)) = &reply_event.relates_to); - assert_eq!(in_reply_to.event_id, event_id); + assert_eq!(reply.in_reply_to.event_id, event_id); } #[async_test] diff --git a/testing/matrix-sdk-test/src/event_factory.rs b/testing/matrix-sdk-test/src/event_factory.rs index 3d3a8e8d9..2fab63a6f 100644 --- a/testing/matrix-sdk-test/src/event_factory.rs +++ b/testing/matrix-sdk-test/src/event_factory.rs @@ -57,7 +57,7 @@ use ruma::{ push_rules::PushRulesEventContent, reaction::ReactionEventContent, receipt::{Receipt, ReceiptEventContent, ReceiptThread, ReceiptType}, - relation::{Annotation, BundledThread, InReplyTo, Reference, Replacement, Thread}, + relation::{Annotation, BundledThread, Reference, Replacement, Reply, Thread}, room::{ ImageInfo, avatar::{self, RoomAvatarEventContent}, @@ -443,8 +443,7 @@ impl EventBuilder { impl EventBuilder { /// Adds a reply relation to the current event. pub fn reply_to(mut self, event_id: &EventId) -> Self { - self.content.relates_to = - Some(Relation::Reply { in_reply_to: InReplyTo::new(event_id.to_owned()) }); + self.content.relates_to = Some(Relation::Reply(Reply::with_event_id(event_id.to_owned()))); self } @@ -518,9 +517,8 @@ impl EventBuilder { /// Adds a reply relation to the current event. pub fn reply_to(mut self, event_id: &EventId) -> Self { if let UnstablePollStartEventContent::New(content) = &mut self.content { - content.relates_to = Some(RelationWithoutReplacement::Reply { - in_reply_to: InReplyTo::new(event_id.to_owned()), - }); + content.relates_to = + Some(RelationWithoutReplacement::Reply(Reply::with_event_id(event_id.to_owned()))); } self }