From f45cb2963a4fd9ac4f2f728ccb678a928cf5b850 Mon Sep 17 00:00:00 2001 From: Devin Ragotzy Date: Tue, 3 Nov 2020 18:51:37 -0500 Subject: [PATCH] Fix formatting and grouping of state_event items --- src/state_event.rs | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/src/state_event.rs b/src/state_event.rs index 477af7b5..3c3471db 100644 --- a/src/state_event.rs +++ b/src/state_event.rs @@ -20,6 +20,8 @@ struct EventIdHelper { event_id: EventId, } +/// This feature is turned on in conduit but off when the tests run because +/// we rely on the EventId to check the state-res. #[cfg(feature = "gen-eventid")] fn event_id(json: &RawJsonValue) -> Result { use std::convert::TryFrom; @@ -31,6 +33,7 @@ fn event_id(json: &RawJsonValue) -> Result { .map_err(de::Error::custom) } +/// Only turned on for testing where we need to keep the ID. #[cfg(not(feature = "gen-eventid"))] fn event_id(json: &RawJsonValue) -> Result { use std::convert::TryFrom; @@ -130,45 +133,6 @@ impl<'de> de::Deserialize<'de> for StateEvent { } } -/// This feature is turned on in conduit but off when the tests run because -/// we rely on the EventId to check the state-res. -#[cfg(feature = "gen-eventid")] -fn event_id(json: &RawJsonValue) -> Result { - use std::convert::TryFrom; - EventId::try_from(format!( - "${}", - reference_hash(&from_raw_json_value(&json)?, &RoomVersionId::Version6) - .map_err(de::Error::custom)?, - )) - .map_err(de::Error::custom) -} - -/// Only turned on for testing where we need to keep the ID. -#[cfg(not(feature = "gen-eventid"))] -fn event_id(json: &RawJsonValue) -> Result { - use std::convert::TryFrom; - Ok(match from_raw_json_value::(&json) { - Ok(id) => id.event_id, - Err(_) => { - // panic!("NOT DURING TESTS"); - EventId::try_from(format!( - "${}", - reference_hash(&from_raw_json_value(&json)?, &RoomVersionId::Version6) - .map_err(de::Error::custom)?, - )) - .map_err(de::Error::custom)? - } - }) -} - -pub struct Requester<'a> { - pub prev_event_ids: Vec, - pub room_id: &'a RoomId, - pub content: &'a serde_json::Value, - pub state_key: Option, - pub sender: &'a UserId, -} - impl StateEvent { pub fn from_id_value(id: EventId, json: serde_json::Value) -> Result { Ok(Self::Full(