fix: deserialize sync event body

This commit is contained in:
timokoesters 2020-04-03 21:17:27 +02:00
parent 2855d1acdf
commit f9cfede2a8
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
4 changed files with 48 additions and 36 deletions

View file

@ -240,8 +240,11 @@ fn create_message_event_route(
MatrixResult(Ok(create_message_event::Response { event_id }))
}
#[get("/_matrix/client/r0/sync")]
fn sync_route(data: State<Data>) -> MatrixResult<sync_events::Response> {
#[get("/_matrix/client/r0/sync", data = "<body>")]
fn sync_route(
data: State<Data>,
body: Ruma<sync_events::Request>,
) -> MatrixResult<sync_events::Response> {
let pdus = data.pdus_all();
let mut joined_rooms = HashMap::new();
joined_rooms.insert(

View file

@ -84,8 +84,11 @@ where
body: t,
user_id,
// TODO: Can we avoid parsing it again?
json_body: serde_json::from_slice(&body)
.expect("Ruma already parsed it successfuly"),
json_body: if !body.is_empty() {
serde_json::from_slice(&body).expect("Ruma already parsed it successfully")
} else {
serde_json::Value::default()
},
}),
Err(e) => {
log::error!("{:?}", e);