fix: all the e2ee problems

This commit is contained in:
Timo Kösters 2022-10-13 10:14:52 +02:00
parent 37eb686b5b
commit ac52b234fa
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
7 changed files with 31 additions and 15 deletions

View file

@ -45,11 +45,21 @@ where
*reqwest_request.timeout_mut() = Some(Duration::from_secs(30));
let url = reqwest_request.url().clone();
let mut response = services()
let mut response = match services()
.globals
.default_client()
.execute(reqwest_request)
.await?;
.await
{
Ok(r) => r,
Err(e) => {
warn!(
"Could not send request to appservice {:?} at {}: {}",
registration.get("id"), destination, e
);
return Err(e.into());
}
};
// reqwest::Response -> http::Response conversion
let status = response.status();

View file

@ -35,6 +35,7 @@ pub async fn send_event_to_device_route(
map.insert(target_device_id_maybe.clone(), event.clone());
let mut messages = BTreeMap::new();
messages.insert(target_user_id.clone(), map);
let count = services().globals.next_count()?;
services().sending.send_reliable_edu(
target_user_id.server_name(),
@ -42,12 +43,12 @@ pub async fn send_event_to_device_route(
DirectDeviceContent {
sender: sender_user.clone(),
ev_type: ToDeviceEventType::from(&*body.event_type),
message_id: body.txn_id.to_owned(),
message_id: count.to_string().into(),
messages,
},
))
.expect("DirectToDevice EDU can be serialized"),
services().globals.next_count()?,
count,
)?;
continue;

View file

@ -281,7 +281,7 @@ where
debug!("{:?}", http_request);
let body = T::try_from_http_request(http_request, &path_params).map_err(|e| {
warn!("{:?}", e);
warn!("{:?}\n{:?}", e, json_body);
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
})?;

View file

@ -304,7 +304,10 @@ where
))
}
}
Err(e) => Err(e.into()),
Err(e) => {
warn!("Could not send request to {} at {}: {}", destination, actual_destination_str, e);
Err(e.into())
},
}
}
@ -831,7 +834,8 @@ pub async fn send_transaction_message_route(
target_user_id,
target_device_id,
&ev_type.to_string(),
event.deserialize_as().map_err(|_| {
event.deserialize_as().map_err(|e| {
warn!("To-Device event is invalid: {event:?} {e}");
Error::BadRequest(
ErrorKind::InvalidParam,
"Event is invalid",