Upgrade Ruma
This commit is contained in:
parent
9db0473ed5
commit
50b24b37c2
6 changed files with 34 additions and 32 deletions
|
@ -23,13 +23,10 @@ pub async fn get_context_route(
|
|||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
||||
// Load filter
|
||||
let filter = body.filter.clone().unwrap_or_default();
|
||||
|
||||
let (lazy_load_enabled, lazy_load_send_redundant) = match filter.lazy_load_options {
|
||||
let (lazy_load_enabled, lazy_load_send_redundant) = match &body.filter.lazy_load_options {
|
||||
LazyLoadOptions::Enabled {
|
||||
include_redundant_members: redundant,
|
||||
} => (true, redundant),
|
||||
include_redundant_members,
|
||||
} => (true, *include_redundant_members),
|
||||
_ => (false, false),
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ pub async fn search_events_route(
|
|||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let search_criteria = body.search_categories.room_events.as_ref().unwrap();
|
||||
let filter = search_criteria.filter.clone().unwrap_or_default();
|
||||
let filter = &search_criteria.filter;
|
||||
|
||||
let room_ids = filter.rooms.clone().unwrap_or_else(|| {
|
||||
db.rooms
|
||||
|
|
|
@ -77,6 +77,9 @@ pub enum Error {
|
|||
#[cfg(feature = "conduit_bin")]
|
||||
#[error("{0}")]
|
||||
ExtensionError(#[from] axum::extract::rejection::ExtensionRejection),
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
#[error("{0}")]
|
||||
PathError(#[from] axum::extract::rejection::PathRejection),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
|
|
|
@ -3,7 +3,9 @@ use std::{collections::BTreeMap, iter::FromIterator, str};
|
|||
use axum::{
|
||||
async_trait,
|
||||
body::{Full, HttpBody},
|
||||
extract::{rejection::TypedHeaderRejectionReason, FromRequest, RequestParts, TypedHeader},
|
||||
extract::{
|
||||
rejection::TypedHeaderRejectionReason, FromRequest, Path, RequestParts, TypedHeader,
|
||||
},
|
||||
headers::{
|
||||
authorization::{Bearer, Credentials},
|
||||
Authorization,
|
||||
|
@ -45,6 +47,7 @@ where
|
|||
let metadata = T::Incoming::METADATA;
|
||||
let db = DatabaseGuard::from_request(req).await?;
|
||||
let auth_header = Option::<TypedHeader<Authorization<Bearer>>>::from_request(req).await?;
|
||||
let path_params = Path::<Vec<String>>::from_request(req).await?;
|
||||
|
||||
let query = req.uri().query().unwrap_or_default();
|
||||
let query_params: QueryParams = match ruma::serde::urlencoded::from_str(query) {
|
||||
|
@ -281,11 +284,10 @@ where
|
|||
|
||||
debug!("{:?}", http_request);
|
||||
|
||||
let body =
|
||||
<T::Incoming as IncomingRequest>::try_from_http_request(http_request).map_err(|e| {
|
||||
warn!("{:?}", e);
|
||||
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
|
||||
})?;
|
||||
let body = T::Incoming::try_from_http_request(http_request, &path_params).map_err(|e| {
|
||||
warn!("{:?}", e);
|
||||
Error::BadRequest(ErrorKind::BadJson, "Failed to deserialize request.")
|
||||
})?;
|
||||
|
||||
Ok(Ruma {
|
||||
body,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue