From 5c0b0cdc6413764e53fc015a4bf89edc92f13ff2 Mon Sep 17 00:00:00 2001 From: "Andriy Kushnir (Orhideous)" Date: Mon, 28 Nov 2022 01:43:17 +0200 Subject: [PATCH] refactor: Replace re-serialization with plain coercion --- src/api/server_server.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 8dee3974..cce4b931 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -1108,14 +1108,14 @@ fn get_missing_events( // event's prev_events. stop_at_events.insert(queued_events[i].clone()); + let prev_events = pdu + .get("prev_events") + .ok_or_else(|| Error::bad_database("Event in db has no prev_events field."))?; + queued_events.extend_from_slice( - &serde_json::from_value::>( - serde_json::to_value(pdu.get("prev_events").cloned().ok_or_else(|| { - Error::bad_database("Event in db has no prev_events field.") - })?) - .expect("canonical json is valid json value"), - ) - .map_err(|_| Error::bad_database("Invalid prev_events content in pdu in db."))?, + &serde_json::from_value::>(prev_events.clone().into()).map_err( + |_| Error::bad_database("Invalid prev_events content in pdu in db."), + )?, ); events.push(PduEvent::convert_to_outgoing_federation_event(pdu)); }