From 22cca206ba50c7eb44bbcd0e330ff3adf117db8f Mon Sep 17 00:00:00 2001 From: timokoesters Date: Mon, 30 Mar 2020 15:38:25 +0200 Subject: [PATCH] Todo: ruma signatures This commit will get force pushed away later --- Cargo.toml | 1 + src/main.rs | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3adca540..13b38f38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,4 @@ ruma-api = "0.15.0" ruma-events = "0.18.0" js_int = "0.1.3" serde_json = "1.0.50" +ruma-signatures = "0.5.0" diff --git a/src/main.rs b/src/main.rs index cf1f37f7..6cf5477b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -218,20 +218,21 @@ fn create_message_event_route( _txn_id: String, body: Ruma, ) -> MatrixResult { + // Construct event + let event = Event::RoomMessage(MessageEvent { + content: body.data.clone().into_result().unwrap(), + event_id: event_id.clone(), + origin_server_ts: utils::millis_since_unix_epoch(), + room_id: Some(body.room_id.clone()), + sender: body.user_id.clone().expect("user is authenticated"), + unsigned: Map::default(), + }); + // Generate event id + dbg!(ruma_signatures::reference_hash(event)); + let event_id = EventId::try_from("$TODOrandomeventid:localhost").unwrap(); - data.event_add( - &body.room_id, - &event_id, - &Event::RoomMessage(MessageEvent { - content: body.data.clone().into_result().unwrap(), - event_id: event_id.clone(), - origin_server_ts: utils::millis_since_unix_epoch(), - room_id: Some(body.room_id.clone()), - sender: body.user_id.clone().expect("user is authenticated"), - unsigned: Map::default(), - }), - ); + data.event_add(&body.room_id, &event_id, &event); MatrixResult(Ok(create_message_event::Response { event_id })) }