don't automatically wrap in RumaResponse

This allows us to use the `ruma_route` convenience function even when we
need to add our own hacks into the responses, thus making us less
reliant on Ruma.
This commit is contained in:
Charles Hall 2024-05-18 18:31:36 -07:00
parent 87ac0e2a38
commit 230ebd3884
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
35 changed files with 438 additions and 405 deletions

View file

@ -74,7 +74,8 @@ use crate::{
#[allow(clippy::too_many_lines)]
pub(crate) async fn sync_events_route(
body: Ruma<sync_events::v3::Request>,
) -> Result<sync_events::v3::Response, RumaResponse<UiaaResponse>> {
) -> Result<RumaResponse<sync_events::v3::Response>, RumaResponse<UiaaResponse>>
{
let sender_user = body.sender_user.expect("user is authenticated");
let sender_device = body.sender_device.expect("user is authenticated");
let body = body.body;
@ -457,10 +458,10 @@ pub(crate) async fn sync_events_route(
Ok(x) => x.expect("watcher should succeed"),
Err(error) => debug!(%error, "timed out"),
};
Ok(response)
Ok(RumaResponse(response))
} else {
// Only cache if we made progress
Ok(response)
Ok(RumaResponse(response))
}
}
@ -1127,7 +1128,8 @@ fn share_encrypted_room(
#[allow(clippy::too_many_lines)]
pub(crate) async fn sync_events_v4_route(
body: Ruma<sync_events::v4::Request>,
) -> Result<sync_events::v4::Response, RumaResponse<UiaaResponse>> {
) -> Result<RumaResponse<sync_events::v4::Response>, RumaResponse<UiaaResponse>>
{
let sender_user = body.sender_user.expect("user is authenticated");
let sender_device = body.sender_device.expect("user is authenticated");
let mut body = body.body;
@ -1700,7 +1702,7 @@ pub(crate) async fn sync_events_v4_route(
};
}
Ok(sync_events::v4::Response {
Ok(RumaResponse(sync_events::v4::Response {
initial: globalsince == 0,
txn_id: body.txn_id.clone(),
pos: next_batch.to_string(),
@ -1763,5 +1765,5 @@ pub(crate) async fn sync_events_v4_route(
},
},
delta_token: None,
})
}))
}