fix: deserialize sync event body
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user