From 26b0f738a5f4ed07a11d5d3c8e7953b2a88b7df6 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Tue, 27 Oct 2020 18:44:29 -0400 Subject: [PATCH] Fix unstable-pre-spec for federation membership join --- Cargo.toml | 7 ++++--- src/state_event.rs | 10 ++++++++-- src/state_store.rs | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f341ec18..b0f416ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,10 @@ thiserror = "1.0.20" tracing-subscriber = "0.2.11" [dependencies.ruma] -git = "https://github.com/ruma/ruma" -rev = "8049631827ab8557cb1010d195dd6468f90effa8" -features = ["client-api", "federation-api", "appservice-api"] +# git = "https://github.com/ruma/ruma" +path = "../__forks__/ruma/ruma" +# rev = "64b9c646d15a359d62ab464a95176ff94adb2554" +features = ["client-api", "federation-api", "appservice-api", "unstable-pre-spec", "unstable-synapse-quirks"] #[dependencies.ruma] #path = "../ruma/ruma" diff --git a/src/state_event.rs b/src/state_event.rs index ad1a0594..fafbec53 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -125,7 +125,12 @@ impl StateEvent { Self::Full(ev) => match ev { Pdu::RoomV1Pdu(ev) => ev.event_id.clone(), Pdu::RoomV3Pdu(ev) => { - let value = serde_json::to_value(ev).expect("all ruma pdus are json values"); + let mut value = serde_json::from_slice::>( + &serde_json::to_vec(ev).expect("all ruma pdus are json values"), + ) + .unwrap(); + value.remove("event_id"); + EventId::try_from(&*format!( "${}", ruma::signatures::reference_hash(&value, &self.room_version()) @@ -195,7 +200,8 @@ impl StateEvent { PduStub::RoomV1PduStub(ev) => ev.state_key.clone(), PduStub::RoomV3PduStub(ev) => ev.state_key.clone(), }, - }.expect("All state events have a state key") + } + .expect("All state events have a state key") } #[cfg(not(feature = "unstable-pre-spec"))] diff --git a/src/state_store.rs b/src/state_store.rs index c1695fa4..2f18692e 100644 --- a/src/state_store.rs +++ b/src/state_store.rs @@ -31,7 +31,7 @@ pub trait StateStore { result.push(ev_id.clone()); - let event = self.get_event(room_id, &ev_id).unwrap(); + let event = self.get_event(room_id, &ev_id)?; stack.extend(event.auth_events()); }