mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
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:
parent
87ac0e2a38
commit
230ebd3884
35 changed files with 438 additions and 405 deletions
|
|
@ -23,7 +23,7 @@ use serde_json::json;
|
|||
use tracing::debug;
|
||||
|
||||
use super::SESSION_ID_LENGTH;
|
||||
use crate::{services, utils, Error, Result, Ruma};
|
||||
use crate::{services, utils, Error, Result, Ruma, RumaResponse};
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/upload`
|
||||
///
|
||||
|
|
@ -34,7 +34,7 @@ use crate::{services, utils, Error, Result, Ruma};
|
|||
/// existing keys?)
|
||||
pub(crate) async fn upload_keys_route(
|
||||
body: Ruma<upload_keys::v3::Request>,
|
||||
) -> Result<upload_keys::v3::Response> {
|
||||
) -> Result<RumaResponse<upload_keys::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device =
|
||||
body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
|
@ -64,11 +64,11 @@ pub(crate) async fn upload_keys_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(upload_keys::v3::Response {
|
||||
Ok(RumaResponse(upload_keys::v3::Response {
|
||||
one_time_key_counts: services()
|
||||
.users
|
||||
.count_one_time_keys(sender_user, sender_device)?,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/query`
|
||||
|
|
@ -81,7 +81,7 @@ pub(crate) async fn upload_keys_route(
|
|||
/// allowed to see
|
||||
pub(crate) async fn get_keys_route(
|
||||
body: Ruma<get_keys::v3::Request>,
|
||||
) -> Result<get_keys::v3::Response> {
|
||||
) -> Result<RumaResponse<get_keys::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let response = get_keys_helper(Some(sender_user), &body.device_keys, |u| {
|
||||
|
|
@ -89,7 +89,7 @@ pub(crate) async fn get_keys_route(
|
|||
})
|
||||
.await?;
|
||||
|
||||
Ok(response)
|
||||
Ok(RumaResponse(response))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/claim`
|
||||
|
|
@ -97,10 +97,10 @@ pub(crate) async fn get_keys_route(
|
|||
/// Claims one-time keys
|
||||
pub(crate) async fn claim_keys_route(
|
||||
body: Ruma<claim_keys::v3::Request>,
|
||||
) -> Result<claim_keys::v3::Response> {
|
||||
) -> Result<RumaResponse<claim_keys::v3::Response>> {
|
||||
let response = claim_keys_helper(&body.one_time_keys).await?;
|
||||
|
||||
Ok(response)
|
||||
Ok(RumaResponse(response))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/device_signing/upload`
|
||||
|
|
@ -110,7 +110,7 @@ pub(crate) async fn claim_keys_route(
|
|||
/// - Requires UIAA to verify password
|
||||
pub(crate) async fn upload_signing_keys_route(
|
||||
body: Ruma<upload_signing_keys::v3::Request>,
|
||||
) -> Result<upload_signing_keys::v3::Response> {
|
||||
) -> Result<RumaResponse<upload_signing_keys::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device =
|
||||
body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
|
@ -156,7 +156,7 @@ pub(crate) async fn upload_signing_keys_route(
|
|||
)?;
|
||||
}
|
||||
|
||||
Ok(upload_signing_keys::v3::Response {})
|
||||
Ok(RumaResponse(upload_signing_keys::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/signatures/upload`
|
||||
|
|
@ -164,7 +164,7 @@ pub(crate) async fn upload_signing_keys_route(
|
|||
/// Uploads end-to-end key signatures from the sender user.
|
||||
pub(crate) async fn upload_signatures_route(
|
||||
body: Ruma<upload_signatures::v3::Request>,
|
||||
) -> Result<upload_signatures::v3::Response> {
|
||||
) -> Result<RumaResponse<upload_signatures::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
for (user_id, keys) in &body.signed_keys {
|
||||
|
|
@ -213,10 +213,10 @@ pub(crate) async fn upload_signatures_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(upload_signatures::v3::Response {
|
||||
Ok(RumaResponse(upload_signatures::v3::Response {
|
||||
// TODO: integrate
|
||||
failures: BTreeMap::new(),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/changes`
|
||||
|
|
@ -227,7 +227,7 @@ pub(crate) async fn upload_signatures_route(
|
|||
/// - TODO: left users
|
||||
pub(crate) async fn get_key_changes_route(
|
||||
body: Ruma<get_key_changes::v3::Request>,
|
||||
) -> Result<get_key_changes::v3::Response> {
|
||||
) -> Result<RumaResponse<get_key_changes::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let mut device_list_updates = HashSet::new();
|
||||
|
|
@ -277,11 +277,11 @@ pub(crate) async fn get_key_changes_route(
|
|||
.filter_map(Result::ok),
|
||||
);
|
||||
}
|
||||
Ok(get_key_changes::v3::Response {
|
||||
Ok(RumaResponse(get_key_changes::v3::Response {
|
||||
changed: device_list_updates.into_iter().collect(),
|
||||
// TODO
|
||||
left: Vec::new(),
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue