mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
rename RumaResponse to Ra
It's very commonly used so having a short name is worthwhile, I think.
This commit is contained in:
parent
230ebd3884
commit
7ea98dac72
38 changed files with 332 additions and 351 deletions
|
|
@ -19,9 +19,7 @@ use ruma::{
|
|||
use tracing::{info, warn};
|
||||
|
||||
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
||||
use crate::{
|
||||
api::client_server, services, utils, Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{api::client_server, services, utils, Error, Ra, Result, Ruma};
|
||||
|
||||
const RANDOM_USER_ID_LENGTH: usize = 10;
|
||||
|
||||
|
|
@ -38,7 +36,7 @@ const RANDOM_USER_ID_LENGTH: usize = 10;
|
|||
/// invalid when trying to register
|
||||
pub(crate) async fn get_register_available_route(
|
||||
body: Ruma<get_username_availability::v3::Request>,
|
||||
) -> Result<RumaResponse<get_username_availability::v3::Response>> {
|
||||
) -> Result<Ra<get_username_availability::v3::Response>> {
|
||||
// Validate user id
|
||||
let user_id = UserId::parse_with_server_name(
|
||||
body.username.to_lowercase(),
|
||||
|
|
@ -65,7 +63,7 @@ pub(crate) async fn get_register_available_route(
|
|||
// TODO add check for appservice namespaces
|
||||
|
||||
// If no if check is true we have an username that's available to be used.
|
||||
Ok(RumaResponse(get_username_availability::v3::Response {
|
||||
Ok(Ra(get_username_availability::v3::Response {
|
||||
available: true,
|
||||
}))
|
||||
}
|
||||
|
|
@ -90,7 +88,7 @@ pub(crate) async fn get_register_available_route(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn register_route(
|
||||
body: Ruma<register::v3::Request>,
|
||||
) -> Result<RumaResponse<register::v3::Response>> {
|
||||
) -> Result<Ra<register::v3::Response>> {
|
||||
if !services().globals.allow_registration()
|
||||
&& body.appservice_info.is_none()
|
||||
{
|
||||
|
|
@ -250,7 +248,7 @@ pub(crate) async fn register_route(
|
|||
|
||||
// Inhibit login does not work for guests
|
||||
if !is_guest && body.inhibit_login {
|
||||
return Ok(RumaResponse(register::v3::Response {
|
||||
return Ok(Ra(register::v3::Response {
|
||||
access_token: None,
|
||||
user_id,
|
||||
device_id: None,
|
||||
|
|
@ -302,7 +300,7 @@ pub(crate) async fn register_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(register::v3::Response {
|
||||
Ok(Ra(register::v3::Response {
|
||||
access_token: Some(token),
|
||||
user_id,
|
||||
device_id: Some(device_id),
|
||||
|
|
@ -330,7 +328,7 @@ pub(crate) async fn register_route(
|
|||
/// - Triggers device list updates
|
||||
pub(crate) async fn change_password_route(
|
||||
body: Ruma<change_password::v3::Request>,
|
||||
) -> Result<RumaResponse<change_password::v3::Response>> {
|
||||
) -> Result<Ra<change_password::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");
|
||||
|
|
@ -383,7 +381,7 @@ pub(crate) async fn change_password_route(
|
|||
format!("User {sender_user} changed their password."),
|
||||
));
|
||||
|
||||
Ok(RumaResponse(change_password::v3::Response {}))
|
||||
Ok(Ra(change_password::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET _matrix/client/r0/account/whoami`
|
||||
|
|
@ -393,11 +391,11 @@ pub(crate) async fn change_password_route(
|
|||
/// Note: Also works for Application Services
|
||||
pub(crate) async fn whoami_route(
|
||||
body: Ruma<whoami::v3::Request>,
|
||||
) -> Result<RumaResponse<whoami::v3::Response>> {
|
||||
) -> Result<Ra<whoami::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let device_id = body.sender_device.as_ref().cloned();
|
||||
|
||||
Ok(RumaResponse(whoami::v3::Response {
|
||||
Ok(Ra(whoami::v3::Response {
|
||||
user_id: sender_user.clone(),
|
||||
device_id,
|
||||
is_guest: services().users.is_deactivated(sender_user)?
|
||||
|
|
@ -418,7 +416,7 @@ pub(crate) async fn whoami_route(
|
|||
/// - Removes ability to log in again
|
||||
pub(crate) async fn deactivate_route(
|
||||
body: Ruma<deactivate::v3::Request>,
|
||||
) -> Result<RumaResponse<deactivate::v3::Response>> {
|
||||
) -> Result<Ra<deactivate::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");
|
||||
|
|
@ -463,7 +461,7 @@ pub(crate) async fn deactivate_route(
|
|||
format!("User {sender_user} deactivated their account."),
|
||||
));
|
||||
|
||||
Ok(RumaResponse(deactivate::v3::Response {
|
||||
Ok(Ra(deactivate::v3::Response {
|
||||
id_server_unbind_result: ThirdPartyIdRemovalStatus::NoSupport,
|
||||
}))
|
||||
}
|
||||
|
|
@ -475,11 +473,11 @@ pub(crate) async fn deactivate_route(
|
|||
/// - Currently always returns empty list
|
||||
pub(crate) async fn third_party_route(
|
||||
body: Ruma<get_3pids::v3::Request>,
|
||||
) -> Result<RumaResponse<get_3pids::v3::Response>> {
|
||||
) -> Result<Ra<get_3pids::v3::Response>> {
|
||||
let _sender_user =
|
||||
body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
Ok(RumaResponse(get_3pids::v3::Response::new(Vec::new())))
|
||||
Ok(Ra(get_3pids::v3::Response::new(Vec::new())))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/v3/account/3pid/email/requestToken`
|
||||
|
|
@ -491,8 +489,7 @@ pub(crate) async fn third_party_route(
|
|||
/// as a contact option.
|
||||
pub(crate) async fn request_3pid_management_token_via_email_route(
|
||||
_body: Ruma<request_3pid_management_token_via_email::v3::Request>,
|
||||
) -> Result<RumaResponse<request_3pid_management_token_via_email::v3::Response>>
|
||||
{
|
||||
) -> Result<Ra<request_3pid_management_token_via_email::v3::Response>> {
|
||||
Err(Error::BadRequest(
|
||||
ErrorKind::ThreepidDenied,
|
||||
"Third party identifier is not allowed",
|
||||
|
|
@ -506,12 +503,9 @@ pub(crate) async fn request_3pid_management_token_via_email_route(
|
|||
///
|
||||
/// - 403 signals that The homeserver does not allow the third party identifier
|
||||
/// as a contact option.
|
||||
#[rustfmt::skip]
|
||||
pub(crate) async fn request_3pid_management_token_via_msisdn_route(
|
||||
_body: Ruma<request_3pid_management_token_via_msisdn::v3::Request>,
|
||||
)
|
||||
-> Result<RumaResponse<request_3pid_management_token_via_msisdn::v3::Response>>
|
||||
{
|
||||
) -> Result<Ra<request_3pid_management_token_via_msisdn::v3::Response>> {
|
||||
Err(Error::BadRequest(
|
||||
ErrorKind::ThreepidDenied,
|
||||
"Third party identifier is not allowed",
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ use ruma::{
|
|||
OwnedRoomAliasId,
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/directory/room/{roomAlias}`
|
||||
///
|
||||
/// Creates a new room alias on this server.
|
||||
pub(crate) async fn create_alias_route(
|
||||
body: Ruma<create_alias::v3::Request>,
|
||||
) -> Result<RumaResponse<create_alias::v3::Response>> {
|
||||
) -> Result<Ra<create_alias::v3::Response>> {
|
||||
if body.room_alias.server_name() != services().globals.server_name() {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
|
|
@ -46,7 +46,7 @@ pub(crate) async fn create_alias_route(
|
|||
|
||||
services().rooms.alias.set_alias(&body.room_alias, &body.room_id)?;
|
||||
|
||||
Ok(RumaResponse(create_alias::v3::Response::new()))
|
||||
Ok(Ra(create_alias::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `DELETE /_matrix/client/r0/directory/room/{roomAlias}`
|
||||
|
|
@ -57,7 +57,7 @@ pub(crate) async fn create_alias_route(
|
|||
/// - TODO: Update canonical alias event
|
||||
pub(crate) async fn delete_alias_route(
|
||||
body: Ruma<delete_alias::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_alias::v3::Response>> {
|
||||
) -> Result<Ra<delete_alias::v3::Response>> {
|
||||
if body.room_alias.server_name() != services().globals.server_name() {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
|
|
@ -83,7 +83,7 @@ pub(crate) async fn delete_alias_route(
|
|||
|
||||
// TODO: update alt_aliases?
|
||||
|
||||
Ok(RumaResponse(delete_alias::v3::Response::new()))
|
||||
Ok(Ra(delete_alias::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/directory/room/{roomAlias}`
|
||||
|
|
@ -93,8 +93,8 @@ pub(crate) async fn delete_alias_route(
|
|||
/// - TODO: Suggest more servers to join via
|
||||
pub(crate) async fn get_alias_route(
|
||||
body: Ruma<get_alias::v3::Request>,
|
||||
) -> Result<RumaResponse<get_alias::v3::Response>> {
|
||||
get_alias_helper(body.body.room_alias).await.map(RumaResponse)
|
||||
) -> Result<Ra<get_alias::v3::Response>> {
|
||||
get_alias_helper(body.body.room_alias).await.map(Ra)
|
||||
}
|
||||
|
||||
pub(crate) async fn get_alias_helper(
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ use ruma::api::client::{
|
|||
error::ErrorKind,
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/room_keys/version`
|
||||
///
|
||||
/// Creates a new backup.
|
||||
pub(crate) async fn create_backup_version_route(
|
||||
body: Ruma<create_backup_version::v3::Request>,
|
||||
) -> Result<RumaResponse<create_backup_version::v3::Response>> {
|
||||
) -> Result<Ra<create_backup_version::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let version =
|
||||
services().key_backups.create_backup(sender_user, &body.algorithm)?;
|
||||
|
||||
Ok(RumaResponse(create_backup_version::v3::Response {
|
||||
Ok(Ra(create_backup_version::v3::Response {
|
||||
version,
|
||||
}))
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ pub(crate) async fn create_backup_version_route(
|
|||
/// modified.
|
||||
pub(crate) async fn update_backup_version_route(
|
||||
body: Ruma<update_backup_version::v3::Request>,
|
||||
) -> Result<RumaResponse<update_backup_version::v3::Response>> {
|
||||
) -> Result<Ra<update_backup_version::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
services().key_backups.update_backup(
|
||||
sender_user,
|
||||
|
|
@ -40,7 +40,7 @@ pub(crate) async fn update_backup_version_route(
|
|||
&body.algorithm,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(update_backup_version::v3::Response {}))
|
||||
Ok(Ra(update_backup_version::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/room_keys/version`
|
||||
|
|
@ -48,7 +48,7 @@ pub(crate) async fn update_backup_version_route(
|
|||
/// Get information about the latest backup version.
|
||||
pub(crate) async fn get_latest_backup_info_route(
|
||||
body: Ruma<get_latest_backup_info::v3::Request>,
|
||||
) -> Result<RumaResponse<get_latest_backup_info::v3::Response>> {
|
||||
) -> Result<Ra<get_latest_backup_info::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let (version, algorithm) = services()
|
||||
|
|
@ -59,7 +59,7 @@ pub(crate) async fn get_latest_backup_info_route(
|
|||
"Key backup does not exist.",
|
||||
))?;
|
||||
|
||||
Ok(RumaResponse(get_latest_backup_info::v3::Response {
|
||||
Ok(Ra(get_latest_backup_info::v3::Response {
|
||||
algorithm,
|
||||
count: services()
|
||||
.key_backups
|
||||
|
|
@ -76,7 +76,7 @@ pub(crate) async fn get_latest_backup_info_route(
|
|||
/// Get information about an existing backup.
|
||||
pub(crate) async fn get_backup_info_route(
|
||||
body: Ruma<get_backup_info::v3::Request>,
|
||||
) -> Result<RumaResponse<get_backup_info::v3::Response>> {
|
||||
) -> Result<Ra<get_backup_info::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let algorithm = services()
|
||||
.key_backups
|
||||
|
|
@ -86,7 +86,7 @@ pub(crate) async fn get_backup_info_route(
|
|||
"Key backup does not exist.",
|
||||
))?;
|
||||
|
||||
Ok(RumaResponse(get_backup_info::v3::Response {
|
||||
Ok(Ra(get_backup_info::v3::Response {
|
||||
algorithm,
|
||||
count: services()
|
||||
.key_backups
|
||||
|
|
@ -106,12 +106,12 @@ pub(crate) async fn get_backup_info_route(
|
|||
/// to the backup
|
||||
pub(crate) async fn delete_backup_version_route(
|
||||
body: Ruma<delete_backup_version::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_backup_version::v3::Response>> {
|
||||
) -> Result<Ra<delete_backup_version::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().key_backups.delete_backup(sender_user, &body.version)?;
|
||||
|
||||
Ok(RumaResponse(delete_backup_version::v3::Response {}))
|
||||
Ok(Ra(delete_backup_version::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `PUT /_matrix/client/r0/room_keys/keys`
|
||||
|
|
@ -124,7 +124,7 @@ pub(crate) async fn delete_backup_version_route(
|
|||
/// - Returns the new number of keys in this backup and the etag
|
||||
pub(crate) async fn add_backup_keys_route(
|
||||
body: Ruma<add_backup_keys::v3::Request>,
|
||||
) -> Result<RumaResponse<add_backup_keys::v3::Response>> {
|
||||
) -> Result<Ra<add_backup_keys::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if Some(&body.version)
|
||||
|
|
@ -152,7 +152,7 @@ pub(crate) async fn add_backup_keys_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(add_backup_keys::v3::Response {
|
||||
Ok(Ra(add_backup_keys::v3::Response {
|
||||
count: services()
|
||||
.key_backups
|
||||
.count_keys(sender_user, &body.version)?
|
||||
|
|
@ -172,7 +172,7 @@ pub(crate) async fn add_backup_keys_route(
|
|||
/// - Returns the new number of keys in this backup and the etag
|
||||
pub(crate) async fn add_backup_keys_for_room_route(
|
||||
body: Ruma<add_backup_keys_for_room::v3::Request>,
|
||||
) -> Result<RumaResponse<add_backup_keys_for_room::v3::Response>> {
|
||||
) -> Result<Ra<add_backup_keys_for_room::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if Some(&body.version)
|
||||
|
|
@ -198,7 +198,7 @@ pub(crate) async fn add_backup_keys_for_room_route(
|
|||
)?;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(add_backup_keys_for_room::v3::Response {
|
||||
Ok(Ra(add_backup_keys_for_room::v3::Response {
|
||||
count: services()
|
||||
.key_backups
|
||||
.count_keys(sender_user, &body.version)?
|
||||
|
|
@ -218,7 +218,7 @@ pub(crate) async fn add_backup_keys_for_room_route(
|
|||
/// - Returns the new number of keys in this backup and the etag
|
||||
pub(crate) async fn add_backup_keys_for_session_route(
|
||||
body: Ruma<add_backup_keys_for_session::v3::Request>,
|
||||
) -> Result<RumaResponse<add_backup_keys_for_session::v3::Response>> {
|
||||
) -> Result<Ra<add_backup_keys_for_session::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if Some(&body.version)
|
||||
|
|
@ -242,7 +242,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
|
|||
&body.session_data,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(add_backup_keys_for_session::v3::Response {
|
||||
Ok(Ra(add_backup_keys_for_session::v3::Response {
|
||||
count: services()
|
||||
.key_backups
|
||||
.count_keys(sender_user, &body.version)?
|
||||
|
|
@ -257,12 +257,12 @@ pub(crate) async fn add_backup_keys_for_session_route(
|
|||
/// Retrieves all keys from the backup.
|
||||
pub(crate) async fn get_backup_keys_route(
|
||||
body: Ruma<get_backup_keys::v3::Request>,
|
||||
) -> Result<RumaResponse<get_backup_keys::v3::Response>> {
|
||||
) -> Result<Ra<get_backup_keys::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let rooms = services().key_backups.get_all(sender_user, &body.version)?;
|
||||
|
||||
Ok(RumaResponse(get_backup_keys::v3::Response {
|
||||
Ok(Ra(get_backup_keys::v3::Response {
|
||||
rooms,
|
||||
}))
|
||||
}
|
||||
|
|
@ -272,7 +272,7 @@ pub(crate) async fn get_backup_keys_route(
|
|||
/// Retrieves all keys from the backup for a given room.
|
||||
pub(crate) async fn get_backup_keys_for_room_route(
|
||||
body: Ruma<get_backup_keys_for_room::v3::Request>,
|
||||
) -> Result<RumaResponse<get_backup_keys_for_room::v3::Response>> {
|
||||
) -> Result<Ra<get_backup_keys_for_room::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let sessions = services().key_backups.get_room(
|
||||
|
|
@ -281,7 +281,7 @@ pub(crate) async fn get_backup_keys_for_room_route(
|
|||
&body.room_id,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(get_backup_keys_for_room::v3::Response {
|
||||
Ok(Ra(get_backup_keys_for_room::v3::Response {
|
||||
sessions,
|
||||
}))
|
||||
}
|
||||
|
|
@ -291,7 +291,7 @@ pub(crate) async fn get_backup_keys_for_room_route(
|
|||
/// Retrieves a key from the backup.
|
||||
pub(crate) async fn get_backup_keys_for_session_route(
|
||||
body: Ruma<get_backup_keys_for_session::v3::Request>,
|
||||
) -> Result<RumaResponse<get_backup_keys_for_session::v3::Response>> {
|
||||
) -> Result<Ra<get_backup_keys_for_session::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let key_data = services()
|
||||
|
|
@ -307,7 +307,7 @@ pub(crate) async fn get_backup_keys_for_session_route(
|
|||
"Backup key not found for this user's session.",
|
||||
))?;
|
||||
|
||||
Ok(RumaResponse(get_backup_keys_for_session::v3::Response {
|
||||
Ok(Ra(get_backup_keys_for_session::v3::Response {
|
||||
key_data,
|
||||
}))
|
||||
}
|
||||
|
|
@ -317,12 +317,12 @@ pub(crate) async fn get_backup_keys_for_session_route(
|
|||
/// Delete the keys from the backup.
|
||||
pub(crate) async fn delete_backup_keys_route(
|
||||
body: Ruma<delete_backup_keys::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_backup_keys::v3::Response>> {
|
||||
) -> Result<Ra<delete_backup_keys::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().key_backups.delete_all_keys(sender_user, &body.version)?;
|
||||
|
||||
Ok(RumaResponse(delete_backup_keys::v3::Response {
|
||||
Ok(Ra(delete_backup_keys::v3::Response {
|
||||
count: services()
|
||||
.key_backups
|
||||
.count_keys(sender_user, &body.version)?
|
||||
|
|
@ -337,7 +337,7 @@ pub(crate) async fn delete_backup_keys_route(
|
|||
/// Delete the keys from the backup for a given room.
|
||||
pub(crate) async fn delete_backup_keys_for_room_route(
|
||||
body: Ruma<delete_backup_keys_for_room::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_backup_keys_for_room::v3::Response>> {
|
||||
) -> Result<Ra<delete_backup_keys_for_room::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().key_backups.delete_room_keys(
|
||||
|
|
@ -346,7 +346,7 @@ pub(crate) async fn delete_backup_keys_for_room_route(
|
|||
&body.room_id,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(delete_backup_keys_for_room::v3::Response {
|
||||
Ok(Ra(delete_backup_keys_for_room::v3::Response {
|
||||
count: services()
|
||||
.key_backups
|
||||
.count_keys(sender_user, &body.version)?
|
||||
|
|
@ -361,7 +361,7 @@ pub(crate) async fn delete_backup_keys_for_room_route(
|
|||
/// Delete a key from the backup.
|
||||
pub(crate) async fn delete_backup_keys_for_session_route(
|
||||
body: Ruma<delete_backup_keys_for_session::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_backup_keys_for_session::v3::Response>> {
|
||||
) -> Result<Ra<delete_backup_keys_for_session::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().key_backups.delete_room_key(
|
||||
|
|
@ -371,7 +371,7 @@ pub(crate) async fn delete_backup_keys_for_session_route(
|
|||
&body.session_id,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(delete_backup_keys_for_session::v3::Response {
|
||||
Ok(Ra(delete_backup_keys_for_session::v3::Response {
|
||||
count: services()
|
||||
.key_backups
|
||||
.count_keys(sender_user, &body.version)?
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use ruma::api::client::discovery::get_capabilities::{
|
|||
self, Capabilities, RoomVersionStability, RoomVersionsCapability,
|
||||
};
|
||||
|
||||
use crate::{services, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/capabilities`
|
||||
///
|
||||
|
|
@ -12,7 +12,7 @@ use crate::{services, Result, Ruma, RumaResponse};
|
|||
/// of this server.
|
||||
pub(crate) async fn get_capabilities_route(
|
||||
_body: Ruma<get_capabilities::v3::Request>,
|
||||
) -> Result<RumaResponse<get_capabilities::v3::Response>> {
|
||||
) -> Result<Ra<get_capabilities::v3::Response>> {
|
||||
let mut available = BTreeMap::new();
|
||||
for room_version in &services().globals.unstable_room_versions {
|
||||
available.insert(room_version.clone(), RoomVersionStability::Unstable);
|
||||
|
|
@ -27,7 +27,7 @@ pub(crate) async fn get_capabilities_route(
|
|||
available,
|
||||
};
|
||||
|
||||
Ok(RumaResponse(get_capabilities::v3::Response {
|
||||
Ok(Ra(get_capabilities::v3::Response {
|
||||
capabilities,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ use ruma::{
|
|||
use serde::Deserialize;
|
||||
use serde_json::{json, value::RawValue as RawJsonValue};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}`
|
||||
///
|
||||
/// Sets some account data for the sender user.
|
||||
pub(crate) async fn set_global_account_data_route(
|
||||
body: Ruma<set_global_account_data::v3::Request>,
|
||||
) -> Result<RumaResponse<set_global_account_data::v3::Response>> {
|
||||
) -> Result<Ra<set_global_account_data::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let data: serde_json::Value = serde_json::from_str(body.data.json().get())
|
||||
|
|
@ -41,7 +41,7 @@ pub(crate) async fn set_global_account_data_route(
|
|||
}),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(set_global_account_data::v3::Response {}))
|
||||
Ok(Ra(set_global_account_data::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
|
||||
|
|
@ -49,7 +49,7 @@ pub(crate) async fn set_global_account_data_route(
|
|||
/// Sets some room account data for the sender user.
|
||||
pub(crate) async fn set_room_account_data_route(
|
||||
body: Ruma<set_room_account_data::v3::Request>,
|
||||
) -> Result<RumaResponse<set_room_account_data::v3::Response>> {
|
||||
) -> Result<Ra<set_room_account_data::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let data: serde_json::Value = serde_json::from_str(body.data.json().get())
|
||||
|
|
@ -69,7 +69,7 @@ pub(crate) async fn set_room_account_data_route(
|
|||
}),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(set_room_account_data::v3::Response {}))
|
||||
Ok(Ra(set_room_account_data::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/user/{userId}/account_data/{type}`
|
||||
|
|
@ -77,7 +77,7 @@ pub(crate) async fn set_room_account_data_route(
|
|||
/// Gets some account data for the sender user.
|
||||
pub(crate) async fn get_global_account_data_route(
|
||||
body: Ruma<get_global_account_data::v3::Request>,
|
||||
) -> Result<RumaResponse<get_global_account_data::v3::Response>> {
|
||||
) -> Result<Ra<get_global_account_data::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event: Box<RawJsonValue> = services()
|
||||
|
|
@ -92,7 +92,7 @@ pub(crate) async fn get_global_account_data_route(
|
|||
})?
|
||||
.content;
|
||||
|
||||
Ok(RumaResponse(get_global_account_data::v3::Response {
|
||||
Ok(Ra(get_global_account_data::v3::Response {
|
||||
account_data,
|
||||
}))
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ pub(crate) async fn get_global_account_data_route(
|
|||
/// Gets some room account data for the sender user.
|
||||
pub(crate) async fn get_room_account_data_route(
|
||||
body: Ruma<get_room_account_data::v3::Request>,
|
||||
) -> Result<RumaResponse<get_room_account_data::v3::Response>> {
|
||||
) -> Result<Ra<get_room_account_data::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event: Box<RawJsonValue> = services()
|
||||
|
|
@ -117,7 +117,7 @@ pub(crate) async fn get_room_account_data_route(
|
|||
})?
|
||||
.content;
|
||||
|
||||
Ok(RumaResponse(get_room_account_data::v3::Response {
|
||||
Ok(Ra(get_room_account_data::v3::Response {
|
||||
account_data,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use ruma::{
|
|||
};
|
||||
use tracing::error;
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/context`
|
||||
///
|
||||
|
|
@ -21,7 +21,7 @@ use crate::{services, Error, Result, Ruma, RumaResponse};
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn get_context_route(
|
||||
body: Ruma<get_context::v3::Request>,
|
||||
) -> Result<RumaResponse<get_context::v3::Response>> {
|
||||
) -> Result<Ra<get_context::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");
|
||||
|
|
@ -187,5 +187,5 @@ pub(crate) async fn get_context_route(
|
|||
state,
|
||||
};
|
||||
|
||||
Ok(RumaResponse(resp))
|
||||
Ok(Ra(resp))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ use ruma::api::client::{
|
|||
};
|
||||
|
||||
use super::SESSION_ID_LENGTH;
|
||||
use crate::{services, utils, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, utils, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/devices`
|
||||
///
|
||||
/// Get metadata on all devices of the sender user.
|
||||
pub(crate) async fn get_devices_route(
|
||||
body: Ruma<get_devices::v3::Request>,
|
||||
) -> Result<RumaResponse<get_devices::v3::Response>> {
|
||||
) -> Result<Ra<get_devices::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let devices: Vec<device::Device> = services()
|
||||
|
|
@ -24,7 +24,7 @@ pub(crate) async fn get_devices_route(
|
|||
.filter_map(Result::ok)
|
||||
.collect();
|
||||
|
||||
Ok(RumaResponse(get_devices::v3::Response {
|
||||
Ok(Ra(get_devices::v3::Response {
|
||||
devices,
|
||||
}))
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ pub(crate) async fn get_devices_route(
|
|||
/// Get metadata on a single device of the sender user.
|
||||
pub(crate) async fn get_device_route(
|
||||
body: Ruma<get_device::v3::Request>,
|
||||
) -> Result<RumaResponse<get_device::v3::Response>> {
|
||||
) -> Result<Ra<get_device::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let device = services()
|
||||
|
|
@ -42,7 +42,7 @@ pub(crate) async fn get_device_route(
|
|||
.get_device_metadata(sender_user, &body.body.device_id)?
|
||||
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
|
||||
|
||||
Ok(RumaResponse(get_device::v3::Response {
|
||||
Ok(Ra(get_device::v3::Response {
|
||||
device,
|
||||
}))
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ pub(crate) async fn get_device_route(
|
|||
/// Updates the metadata on a given device of the sender user.
|
||||
pub(crate) async fn update_device_route(
|
||||
body: Ruma<update_device::v3::Request>,
|
||||
) -> Result<RumaResponse<update_device::v3::Response>> {
|
||||
) -> Result<Ra<update_device::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let mut device = services()
|
||||
|
|
@ -68,7 +68,7 @@ pub(crate) async fn update_device_route(
|
|||
&device,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(update_device::v3::Response {}))
|
||||
Ok(Ra(update_device::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `DELETE /_matrix/client/r0/devices/{deviceId}`
|
||||
|
|
@ -83,7 +83,7 @@ pub(crate) async fn update_device_route(
|
|||
/// - Triggers device list updates
|
||||
pub(crate) async fn delete_device_route(
|
||||
body: Ruma<delete_device::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_device::v3::Response>> {
|
||||
) -> Result<Ra<delete_device::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");
|
||||
|
|
@ -120,7 +120,7 @@ pub(crate) async fn delete_device_route(
|
|||
|
||||
services().users.remove_device(sender_user, &body.device_id)?;
|
||||
|
||||
Ok(RumaResponse(delete_device::v3::Response {}))
|
||||
Ok(Ra(delete_device::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
|
||||
|
|
@ -137,7 +137,7 @@ pub(crate) async fn delete_device_route(
|
|||
/// - Triggers device list updates
|
||||
pub(crate) async fn delete_devices_route(
|
||||
body: Ruma<delete_devices::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_devices::v3::Response>> {
|
||||
) -> Result<Ra<delete_devices::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");
|
||||
|
|
@ -176,5 +176,5 @@ pub(crate) async fn delete_devices_route(
|
|||
services().users.remove_device(sender_user, device_id)?;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(delete_devices::v3::Response {}))
|
||||
Ok(Ra(delete_devices::v3::Response {}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use ruma::{
|
|||
};
|
||||
use tracing::{error, info, warn};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/publicRooms`
|
||||
///
|
||||
|
|
@ -38,7 +38,7 @@ use crate::{services, Error, Result, Ruma, RumaResponse};
|
|||
/// - Rooms are ordered by the number of joined members
|
||||
pub(crate) async fn get_public_rooms_filtered_route(
|
||||
body: Ruma<get_public_rooms_filtered::v3::Request>,
|
||||
) -> Result<RumaResponse<get_public_rooms_filtered::v3::Response>> {
|
||||
) -> Result<Ra<get_public_rooms_filtered::v3::Response>> {
|
||||
get_public_rooms_filtered_helper(
|
||||
body.server.as_deref(),
|
||||
body.limit,
|
||||
|
|
@ -47,7 +47,7 @@ pub(crate) async fn get_public_rooms_filtered_route(
|
|||
&body.room_network,
|
||||
)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
.map(Ra)
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/publicRooms`
|
||||
|
|
@ -57,7 +57,7 @@ pub(crate) async fn get_public_rooms_filtered_route(
|
|||
/// - Rooms are ordered by the number of joined members
|
||||
pub(crate) async fn get_public_rooms_route(
|
||||
body: Ruma<get_public_rooms::v3::Request>,
|
||||
) -> Result<RumaResponse<get_public_rooms::v3::Response>> {
|
||||
) -> Result<Ra<get_public_rooms::v3::Response>> {
|
||||
let response = get_public_rooms_filtered_helper(
|
||||
body.server.as_deref(),
|
||||
body.limit,
|
||||
|
|
@ -67,7 +67,7 @@ pub(crate) async fn get_public_rooms_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_public_rooms::v3::Response {
|
||||
Ok(Ra(get_public_rooms::v3::Response {
|
||||
chunk: response.chunk,
|
||||
prev_batch: response.prev_batch,
|
||||
next_batch: response.next_batch,
|
||||
|
|
@ -82,7 +82,7 @@ pub(crate) async fn get_public_rooms_route(
|
|||
/// - TODO: Access control checks
|
||||
pub(crate) async fn set_room_visibility_route(
|
||||
body: Ruma<set_room_visibility::v3::Request>,
|
||||
) -> Result<RumaResponse<set_room_visibility::v3::Response>> {
|
||||
) -> Result<Ra<set_room_visibility::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services().rooms.metadata.exists(&body.room_id)? {
|
||||
|
|
@ -106,7 +106,7 @@ pub(crate) async fn set_room_visibility_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(set_room_visibility::v3::Response {}))
|
||||
Ok(Ra(set_room_visibility::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/directory/list/room/{roomId}`
|
||||
|
|
@ -114,13 +114,13 @@ pub(crate) async fn set_room_visibility_route(
|
|||
/// Gets the visibility of a given room in the room directory.
|
||||
pub(crate) async fn get_room_visibility_route(
|
||||
body: Ruma<get_room_visibility::v3::Request>,
|
||||
) -> Result<RumaResponse<get_room_visibility::v3::Response>> {
|
||||
) -> Result<Ra<get_room_visibility::v3::Response>> {
|
||||
if !services().rooms.metadata.exists(&body.room_id)? {
|
||||
// Return 404 if the room doesn't exist
|
||||
return Err(Error::BadRequest(ErrorKind::NotFound, "Room not found"));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_room_visibility::v3::Response {
|
||||
Ok(Ra(get_room_visibility::v3::Response {
|
||||
visibility: if services()
|
||||
.rooms
|
||||
.directory
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use ruma::api::client::{
|
|||
filter::{create_filter, get_filter},
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
|
||||
///
|
||||
|
|
@ -12,7 +12,7 @@ use crate::{services, Error, Result, Ruma, RumaResponse};
|
|||
/// - A user can only access their own filters
|
||||
pub(crate) async fn get_filter_route(
|
||||
body: Ruma<get_filter::v3::Request>,
|
||||
) -> Result<RumaResponse<get_filter::v3::Response>> {
|
||||
) -> Result<Ra<get_filter::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let Some(filter) =
|
||||
services().users.get_filter(sender_user, &body.filter_id)?
|
||||
|
|
@ -23,7 +23,7 @@ pub(crate) async fn get_filter_route(
|
|||
));
|
||||
};
|
||||
|
||||
Ok(RumaResponse(get_filter::v3::Response::new(filter)))
|
||||
Ok(Ra(get_filter::v3::Response::new(filter)))
|
||||
}
|
||||
|
||||
/// # `PUT /_matrix/client/r0/user/{userId}/filter`
|
||||
|
|
@ -31,9 +31,9 @@ pub(crate) async fn get_filter_route(
|
|||
/// Creates a new filter to be used by other endpoints.
|
||||
pub(crate) async fn create_filter_route(
|
||||
body: Ruma<create_filter::v3::Request>,
|
||||
) -> Result<RumaResponse<create_filter::v3::Response>> {
|
||||
) -> Result<Ra<create_filter::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
Ok(RumaResponse(create_filter::v3::Response::new(
|
||||
Ok(Ra(create_filter::v3::Response::new(
|
||||
services().users.create_filter(sender_user, &body.filter)?,
|
||||
)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use serde_json::json;
|
|||
use tracing::debug;
|
||||
|
||||
use super::SESSION_ID_LENGTH;
|
||||
use crate::{services, utils, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, utils, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/keys/upload`
|
||||
///
|
||||
|
|
@ -34,7 +34,7 @@ use crate::{services, utils, Error, Result, Ruma, RumaResponse};
|
|||
/// existing keys?)
|
||||
pub(crate) async fn upload_keys_route(
|
||||
body: Ruma<upload_keys::v3::Request>,
|
||||
) -> Result<RumaResponse<upload_keys::v3::Response>> {
|
||||
) -> Result<Ra<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,7 +64,7 @@ pub(crate) async fn upload_keys_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(upload_keys::v3::Response {
|
||||
Ok(Ra(upload_keys::v3::Response {
|
||||
one_time_key_counts: services()
|
||||
.users
|
||||
.count_one_time_keys(sender_user, sender_device)?,
|
||||
|
|
@ -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<RumaResponse<get_keys::v3::Response>> {
|
||||
) -> Result<Ra<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(RumaResponse(response))
|
||||
Ok(Ra(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<RumaResponse<claim_keys::v3::Response>> {
|
||||
) -> Result<Ra<claim_keys::v3::Response>> {
|
||||
let response = claim_keys_helper(&body.one_time_keys).await?;
|
||||
|
||||
Ok(RumaResponse(response))
|
||||
Ok(Ra(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<RumaResponse<upload_signing_keys::v3::Response>> {
|
||||
) -> Result<Ra<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(RumaResponse(upload_signing_keys::v3::Response {}))
|
||||
Ok(Ra(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<RumaResponse<upload_signatures::v3::Response>> {
|
||||
) -> Result<Ra<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,7 +213,7 @@ pub(crate) async fn upload_signatures_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(upload_signatures::v3::Response {
|
||||
Ok(Ra(upload_signatures::v3::Response {
|
||||
// TODO: integrate
|
||||
failures: BTreeMap::new(),
|
||||
}))
|
||||
|
|
@ -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<RumaResponse<get_key_changes::v3::Response>> {
|
||||
) -> Result<Ra<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,7 +277,7 @@ pub(crate) async fn get_key_changes_route(
|
|||
.filter_map(Result::ok),
|
||||
);
|
||||
}
|
||||
Ok(RumaResponse(get_key_changes::v3::Response {
|
||||
Ok(Ra(get_key_changes::v3::Response {
|
||||
changed: device_list_updates.into_iter().collect(),
|
||||
// TODO
|
||||
left: Vec::new(),
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ use ruma::api::client::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
service::media::FileMeta, services, utils, Error, Result, Ruma,
|
||||
RumaResponse,
|
||||
service::media::FileMeta, services, utils, Error, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
const MXC_LENGTH: usize = 32;
|
||||
|
|
@ -20,8 +19,8 @@ const MXC_LENGTH: usize = 32;
|
|||
/// Returns max upload size.
|
||||
pub(crate) async fn get_media_config_route(
|
||||
_body: Ruma<get_media_config::v3::Request>,
|
||||
) -> Result<RumaResponse<get_media_config::v3::Response>> {
|
||||
Ok(RumaResponse(get_media_config::v3::Response {
|
||||
) -> Result<Ra<get_media_config::v3::Response>> {
|
||||
Ok(Ra(get_media_config::v3::Response {
|
||||
upload_size: services().globals.max_request_size().into(),
|
||||
}))
|
||||
}
|
||||
|
|
@ -34,7 +33,7 @@ pub(crate) async fn get_media_config_route(
|
|||
/// - Media will be saved in the media/ directory
|
||||
pub(crate) async fn create_content_route(
|
||||
body: Ruma<create_content::v3::Request>,
|
||||
) -> Result<RumaResponse<create_content::v3::Response>> {
|
||||
) -> Result<Ra<create_content::v3::Response>> {
|
||||
let mxc = format!(
|
||||
"mxc://{}/{}",
|
||||
services().globals.server_name(),
|
||||
|
|
@ -54,7 +53,7 @@ pub(crate) async fn create_content_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(create_content::v3::Response {
|
||||
Ok(Ra(create_content::v3::Response {
|
||||
content_uri: mxc.into(),
|
||||
blurhash: None,
|
||||
}))
|
||||
|
|
@ -99,7 +98,7 @@ pub(crate) async fn get_remote_content(
|
|||
/// - Only allows federation if `allow_remote` is true
|
||||
pub(crate) async fn get_content_route(
|
||||
body: Ruma<get_content::v3::Request>,
|
||||
) -> Result<RumaResponse<get_content::v3::Response>> {
|
||||
) -> Result<Ra<get_content::v3::Response>> {
|
||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||
|
||||
if let Some(FileMeta {
|
||||
|
|
@ -108,7 +107,7 @@ pub(crate) async fn get_content_route(
|
|||
file,
|
||||
}) = services().media.get(mxc.clone()).await?
|
||||
{
|
||||
Ok(RumaResponse(get_content::v3::Response {
|
||||
Ok(Ra(get_content::v3::Response {
|
||||
file,
|
||||
content_type,
|
||||
content_disposition,
|
||||
|
|
@ -120,7 +119,7 @@ pub(crate) async fn get_content_route(
|
|||
let remote_content_response =
|
||||
get_remote_content(&mxc, &body.server_name, body.media_id.clone())
|
||||
.await?;
|
||||
Ok(RumaResponse(remote_content_response))
|
||||
Ok(Ra(remote_content_response))
|
||||
} else {
|
||||
Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."))
|
||||
}
|
||||
|
|
@ -133,7 +132,7 @@ pub(crate) async fn get_content_route(
|
|||
/// - Only allows federation if `allow_remote` is true
|
||||
pub(crate) async fn get_content_as_filename_route(
|
||||
body: Ruma<get_content_as_filename::v3::Request>,
|
||||
) -> Result<RumaResponse<get_content_as_filename::v3::Response>> {
|
||||
) -> Result<Ra<get_content_as_filename::v3::Response>> {
|
||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||
|
||||
if let Some(FileMeta {
|
||||
|
|
@ -142,7 +141,7 @@ pub(crate) async fn get_content_as_filename_route(
|
|||
..
|
||||
}) = services().media.get(mxc.clone()).await?
|
||||
{
|
||||
Ok(RumaResponse(get_content_as_filename::v3::Response {
|
||||
Ok(Ra(get_content_as_filename::v3::Response {
|
||||
file,
|
||||
content_type,
|
||||
content_disposition: Some(format!(
|
||||
|
|
@ -158,7 +157,7 @@ pub(crate) async fn get_content_as_filename_route(
|
|||
get_remote_content(&mxc, &body.server_name, body.media_id.clone())
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_content_as_filename::v3::Response {
|
||||
Ok(Ra(get_content_as_filename::v3::Response {
|
||||
content_disposition: Some(format!(
|
||||
"inline: filename={}",
|
||||
body.filename
|
||||
|
|
@ -179,7 +178,7 @@ pub(crate) async fn get_content_as_filename_route(
|
|||
/// - Only allows federation if `allow_remote` is true
|
||||
pub(crate) async fn get_content_thumbnail_route(
|
||||
body: Ruma<get_content_thumbnail::v3::Request>,
|
||||
) -> Result<RumaResponse<get_content_thumbnail::v3::Response>> {
|
||||
) -> Result<Ra<get_content_thumbnail::v3::Response>> {
|
||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||
|
||||
if let Some(FileMeta {
|
||||
|
|
@ -199,7 +198,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
|||
)
|
||||
.await?
|
||||
{
|
||||
Ok(RumaResponse(get_content_thumbnail::v3::Response {
|
||||
Ok(Ra(get_content_thumbnail::v3::Response {
|
||||
file,
|
||||
content_type,
|
||||
cross_origin_resource_policy: Some("cross-origin".to_owned()),
|
||||
|
|
@ -236,7 +235,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_thumbnail_response))
|
||||
Ok(Ra(get_thumbnail_response))
|
||||
} else {
|
||||
Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use tracing::{debug, error, info, warn};
|
|||
use super::get_alias_helper;
|
||||
use crate::{
|
||||
service::pdu::{gen_event_id_canonical_json, PduBuilder},
|
||||
services, utils, Error, PduEvent, Result, Ruma, RumaResponse,
|
||||
services, utils, Error, PduEvent, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/join`
|
||||
|
|
@ -49,7 +49,7 @@ use crate::{
|
|||
/// federation
|
||||
pub(crate) async fn join_room_by_id_route(
|
||||
body: Ruma<join_room_by_id::v3::Request>,
|
||||
) -> Result<RumaResponse<join_room_by_id::v3::Response>> {
|
||||
) -> Result<Ra<join_room_by_id::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
// There is no body.server_name for /roomId/join
|
||||
|
|
@ -83,7 +83,7 @@ pub(crate) async fn join_room_by_id_route(
|
|||
body.third_party_signed.as_ref(),
|
||||
)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
.map(Ra)
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/join/{roomIdOrAlias}`
|
||||
|
|
@ -96,7 +96,7 @@ pub(crate) async fn join_room_by_id_route(
|
|||
/// federation
|
||||
pub(crate) async fn join_room_by_id_or_alias_route(
|
||||
body: Ruma<join_room_by_id_or_alias::v3::Request>,
|
||||
) -> Result<RumaResponse<join_room_by_id_or_alias::v3::Response>> {
|
||||
) -> Result<Ra<join_room_by_id_or_alias::v3::Response>> {
|
||||
let sender_user =
|
||||
body.sender_user.as_deref().expect("user is authenticated");
|
||||
let body = body.body;
|
||||
|
|
@ -148,7 +148,7 @@ pub(crate) async fn join_room_by_id_or_alias_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(join_room_by_id_or_alias::v3::Response {
|
||||
Ok(Ra(join_room_by_id_or_alias::v3::Response {
|
||||
room_id: join_room_response.room_id,
|
||||
}))
|
||||
}
|
||||
|
|
@ -160,12 +160,12 @@ pub(crate) async fn join_room_by_id_or_alias_route(
|
|||
/// - This should always work if the user is currently joined.
|
||||
pub(crate) async fn leave_room_route(
|
||||
body: Ruma<leave_room::v3::Request>,
|
||||
) -> Result<RumaResponse<leave_room::v3::Response>> {
|
||||
) -> Result<Ra<leave_room::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
leave_room(sender_user, &body.room_id, body.reason.clone()).await?;
|
||||
|
||||
Ok(RumaResponse(leave_room::v3::Response::new()))
|
||||
Ok(Ra(leave_room::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/invite`
|
||||
|
|
@ -173,7 +173,7 @@ pub(crate) async fn leave_room_route(
|
|||
/// Tries to send an invite event into the room.
|
||||
pub(crate) async fn invite_user_route(
|
||||
body: Ruma<invite_user::v3::Request>,
|
||||
) -> Result<RumaResponse<invite_user::v3::Response>> {
|
||||
) -> Result<Ra<invite_user::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if let invite_user::v3::InvitationRecipient::UserId {
|
||||
|
|
@ -188,7 +188,7 @@ pub(crate) async fn invite_user_route(
|
|||
false,
|
||||
)
|
||||
.await?;
|
||||
Ok(RumaResponse(invite_user::v3::Response {}))
|
||||
Ok(Ra(invite_user::v3::Response {}))
|
||||
} else {
|
||||
Err(Error::BadRequest(ErrorKind::NotFound, "User not found."))
|
||||
}
|
||||
|
|
@ -199,13 +199,13 @@ pub(crate) async fn invite_user_route(
|
|||
/// Tries to send a kick event into the room.
|
||||
pub(crate) async fn kick_user_route(
|
||||
body: Ruma<kick_user::v3::Request>,
|
||||
) -> Result<RumaResponse<kick_user::v3::Response>> {
|
||||
) -> Result<Ra<kick_user::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if let Ok(true) =
|
||||
services().rooms.state_cache.is_left(sender_user, &body.room_id)
|
||||
{
|
||||
return Ok(RumaResponse(kick_user::v3::Response {}));
|
||||
return Ok(Ra(kick_user::v3::Response {}));
|
||||
}
|
||||
|
||||
let mut event: RoomMemberEventContent = serde_json::from_str(
|
||||
|
|
@ -260,7 +260,7 @@ pub(crate) async fn kick_user_route(
|
|||
|
||||
drop(state_lock);
|
||||
|
||||
Ok(RumaResponse(kick_user::v3::Response::new()))
|
||||
Ok(Ra(kick_user::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/ban`
|
||||
|
|
@ -268,14 +268,14 @@ pub(crate) async fn kick_user_route(
|
|||
/// Tries to send a ban event into the room.
|
||||
pub(crate) async fn ban_user_route(
|
||||
body: Ruma<ban_user::v3::Request>,
|
||||
) -> Result<RumaResponse<ban_user::v3::Response>> {
|
||||
) -> Result<Ra<ban_user::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if let Ok(Some(membership_event)) =
|
||||
services().rooms.state_accessor.get_member(&body.room_id, sender_user)
|
||||
{
|
||||
if membership_event.membership == MembershipState::Ban {
|
||||
return Ok(RumaResponse(ban_user::v3::Response {}));
|
||||
return Ok(Ra(ban_user::v3::Response {}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ pub(crate) async fn ban_user_route(
|
|||
|
||||
drop(state_lock);
|
||||
|
||||
Ok(RumaResponse(ban_user::v3::Response::new()))
|
||||
Ok(Ra(ban_user::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/unban`
|
||||
|
|
@ -352,14 +352,14 @@ pub(crate) async fn ban_user_route(
|
|||
/// Tries to send an unban event into the room.
|
||||
pub(crate) async fn unban_user_route(
|
||||
body: Ruma<unban_user::v3::Request>,
|
||||
) -> Result<RumaResponse<unban_user::v3::Response>> {
|
||||
) -> Result<Ra<unban_user::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if let Ok(Some(membership_event)) =
|
||||
services().rooms.state_accessor.get_member(&body.room_id, sender_user)
|
||||
{
|
||||
if membership_event.membership != MembershipState::Ban {
|
||||
return Ok(RumaResponse(unban_user::v3::Response {}));
|
||||
return Ok(Ra(unban_user::v3::Response {}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -415,7 +415,7 @@ pub(crate) async fn unban_user_route(
|
|||
|
||||
drop(state_lock);
|
||||
|
||||
Ok(RumaResponse(unban_user::v3::Response::new()))
|
||||
Ok(Ra(unban_user::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/forget`
|
||||
|
|
@ -429,12 +429,12 @@ pub(crate) async fn unban_user_route(
|
|||
/// forgotten, so this has to be called from every device
|
||||
pub(crate) async fn forget_room_route(
|
||||
body: Ruma<forget_room::v3::Request>,
|
||||
) -> Result<RumaResponse<forget_room::v3::Response>> {
|
||||
) -> Result<Ra<forget_room::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().rooms.state_cache.forget(&body.room_id, sender_user)?;
|
||||
|
||||
Ok(RumaResponse(forget_room::v3::Response::new()))
|
||||
Ok(Ra(forget_room::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/joined_rooms`
|
||||
|
|
@ -442,10 +442,10 @@ pub(crate) async fn forget_room_route(
|
|||
/// Lists all rooms the user has joined.
|
||||
pub(crate) async fn joined_rooms_route(
|
||||
body: Ruma<joined_rooms::v3::Request>,
|
||||
) -> Result<RumaResponse<joined_rooms::v3::Response>> {
|
||||
) -> Result<Ra<joined_rooms::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
Ok(RumaResponse(joined_rooms::v3::Response {
|
||||
Ok(Ra(joined_rooms::v3::Response {
|
||||
joined_rooms: services()
|
||||
.rooms
|
||||
.state_cache
|
||||
|
|
@ -463,7 +463,7 @@ pub(crate) async fn joined_rooms_route(
|
|||
/// - Only works if the user is currently joined
|
||||
pub(crate) async fn get_member_events_route(
|
||||
body: Ruma<get_member_events::v3::Request>,
|
||||
) -> Result<RumaResponse<get_member_events::v3::Response>> {
|
||||
) -> Result<Ra<get_member_events::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services()
|
||||
|
|
@ -477,7 +477,7 @@ pub(crate) async fn get_member_events_route(
|
|||
));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_member_events::v3::Response {
|
||||
Ok(Ra(get_member_events::v3::Response {
|
||||
chunk: services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
|
|
@ -498,7 +498,7 @@ pub(crate) async fn get_member_events_route(
|
|||
/// - TODO: An appservice just needs a puppet joined
|
||||
pub(crate) async fn joined_members_route(
|
||||
body: Ruma<joined_members::v3::Request>,
|
||||
) -> Result<RumaResponse<joined_members::v3::Response>> {
|
||||
) -> Result<Ra<joined_members::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services()
|
||||
|
|
@ -531,7 +531,7 @@ pub(crate) async fn joined_members_route(
|
|||
);
|
||||
}
|
||||
|
||||
Ok(RumaResponse(joined_members::v3::Response {
|
||||
Ok(Ra(joined_members::v3::Response {
|
||||
joined,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use ruma::{
|
|||
|
||||
use crate::{
|
||||
service::{pdu::PduBuilder, rooms::timeline::PduCount},
|
||||
services, utils, Error, Result, Ruma, RumaResponse,
|
||||
services, utils, Error, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}`
|
||||
|
|
@ -28,7 +28,7 @@ use crate::{
|
|||
/// allowed
|
||||
pub(crate) async fn send_message_event_route(
|
||||
body: Ruma<send_message_event::v3::Request>,
|
||||
) -> Result<RumaResponse<send_message_event::v3::Response>> {
|
||||
) -> Result<Ra<send_message_event::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device = body.sender_device.as_deref();
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ pub(crate) async fn send_message_event_route(
|
|||
.map_err(|_| {
|
||||
Error::bad_database("Invalid event id in txnid data.")
|
||||
})?;
|
||||
return Ok(RumaResponse(send_message_event::v3::Response {
|
||||
return Ok(Ra(send_message_event::v3::Response {
|
||||
event_id,
|
||||
}));
|
||||
}
|
||||
|
|
@ -118,9 +118,7 @@ pub(crate) async fn send_message_event_route(
|
|||
|
||||
drop(state_lock);
|
||||
|
||||
Ok(RumaResponse(send_message_event::v3::Response::new(
|
||||
(*event_id).to_owned(),
|
||||
)))
|
||||
Ok(Ra(send_message_event::v3::Response::new((*event_id).to_owned())))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/messages`
|
||||
|
|
@ -133,7 +131,7 @@ pub(crate) async fn send_message_event_route(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn get_message_events_route(
|
||||
body: Ruma<get_message_events::v3::Request>,
|
||||
) -> Result<RumaResponse<get_message_events::v3::Response>> {
|
||||
) -> Result<Ra<get_message_events::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");
|
||||
|
|
@ -310,5 +308,5 @@ pub(crate) async fn get_message_events_route(
|
|||
}
|
||||
*/
|
||||
|
||||
Ok(RumaResponse(resp))
|
||||
Ok(Ra(resp))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ use ruma::{
|
|||
use serde_json::value::to_raw_value;
|
||||
use tracing::warn;
|
||||
|
||||
use crate::{
|
||||
service::pdu::PduBuilder, services, Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{service::pdu::PduBuilder, services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/profile/{userId}/displayname`
|
||||
///
|
||||
|
|
@ -29,7 +27,7 @@ use crate::{
|
|||
/// - Also makes sure other users receive the update using presence EDUs
|
||||
pub(crate) async fn set_displayname_route(
|
||||
body: Ruma<set_display_name::v3::Request>,
|
||||
) -> Result<RumaResponse<set_display_name::v3::Response>> {
|
||||
) -> Result<Ra<set_display_name::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().users.set_displayname(sender_user, body.displayname.clone())?;
|
||||
|
|
@ -109,7 +107,7 @@ pub(crate) async fn set_displayname_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(set_display_name::v3::Response {}))
|
||||
Ok(Ra(set_display_name::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/profile/{userId}/displayname`
|
||||
|
|
@ -119,7 +117,7 @@ pub(crate) async fn set_displayname_route(
|
|||
/// - If user is on another server: Fetches displayname over federation
|
||||
pub(crate) async fn get_displayname_route(
|
||||
body: Ruma<get_display_name::v3::Request>,
|
||||
) -> Result<RumaResponse<get_display_name::v3::Response>> {
|
||||
) -> Result<Ra<get_display_name::v3::Response>> {
|
||||
if body.user_id.server_name() != services().globals.server_name() {
|
||||
let response = services()
|
||||
.sending
|
||||
|
|
@ -132,12 +130,12 @@ pub(crate) async fn get_displayname_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
return Ok(RumaResponse(get_display_name::v3::Response {
|
||||
return Ok(Ra(get_display_name::v3::Response {
|
||||
displayname: response.displayname,
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_display_name::v3::Response {
|
||||
Ok(Ra(get_display_name::v3::Response {
|
||||
displayname: services().users.displayname(&body.user_id)?,
|
||||
}))
|
||||
}
|
||||
|
|
@ -149,7 +147,7 @@ pub(crate) async fn get_displayname_route(
|
|||
/// - Also makes sure other users receive the update using presence EDUs
|
||||
pub(crate) async fn set_avatar_url_route(
|
||||
body: Ruma<set_avatar_url::v3::Request>,
|
||||
) -> Result<RumaResponse<set_avatar_url::v3::Response>> {
|
||||
) -> Result<Ra<set_avatar_url::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().users.set_avatar_url(sender_user, body.avatar_url.clone())?;
|
||||
|
|
@ -231,7 +229,7 @@ pub(crate) async fn set_avatar_url_route(
|
|||
};
|
||||
}
|
||||
|
||||
Ok(RumaResponse(set_avatar_url::v3::Response {}))
|
||||
Ok(Ra(set_avatar_url::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/profile/{userId}/avatar_url`
|
||||
|
|
@ -242,7 +240,7 @@ pub(crate) async fn set_avatar_url_route(
|
|||
/// federation
|
||||
pub(crate) async fn get_avatar_url_route(
|
||||
body: Ruma<get_avatar_url::v3::Request>,
|
||||
) -> Result<RumaResponse<get_avatar_url::v3::Response>> {
|
||||
) -> Result<Ra<get_avatar_url::v3::Response>> {
|
||||
if body.user_id.server_name() != services().globals.server_name() {
|
||||
let response = services()
|
||||
.sending
|
||||
|
|
@ -255,13 +253,13 @@ pub(crate) async fn get_avatar_url_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
return Ok(RumaResponse(get_avatar_url::v3::Response {
|
||||
return Ok(Ra(get_avatar_url::v3::Response {
|
||||
avatar_url: response.avatar_url,
|
||||
blurhash: response.blurhash,
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_avatar_url::v3::Response {
|
||||
Ok(Ra(get_avatar_url::v3::Response {
|
||||
avatar_url: services().users.avatar_url(&body.user_id)?,
|
||||
blurhash: services().users.blurhash(&body.user_id)?,
|
||||
}))
|
||||
|
|
@ -274,7 +272,7 @@ pub(crate) async fn get_avatar_url_route(
|
|||
/// - If user is on another server: Fetches profile over federation
|
||||
pub(crate) async fn get_profile_route(
|
||||
body: Ruma<get_profile::v3::Request>,
|
||||
) -> Result<RumaResponse<get_profile::v3::Response>> {
|
||||
) -> Result<Ra<get_profile::v3::Response>> {
|
||||
if body.user_id.server_name() != services().globals.server_name() {
|
||||
let response = services()
|
||||
.sending
|
||||
|
|
@ -287,7 +285,7 @@ pub(crate) async fn get_profile_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
return Ok(RumaResponse(get_profile::v3::Response {
|
||||
return Ok(Ra(get_profile::v3::Response {
|
||||
displayname: response.displayname,
|
||||
avatar_url: response.avatar_url,
|
||||
blurhash: response.blurhash,
|
||||
|
|
@ -302,7 +300,7 @@ pub(crate) async fn get_profile_route(
|
|||
));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_profile::v3::Response {
|
||||
Ok(Ra(get_profile::v3::Response {
|
||||
avatar_url: services().users.avatar_url(&body.user_id)?,
|
||||
blurhash: services().users.blurhash(&body.user_id)?,
|
||||
displayname: services().users.displayname(&body.user_id)?,
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ use ruma::{
|
|||
push::{AnyPushRuleRef, InsertPushRuleError, RemovePushRuleError},
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/pushrules`
|
||||
///
|
||||
/// Retrieves the push rules event for this user.
|
||||
pub(crate) async fn get_pushrules_all_route(
|
||||
body: Ruma<get_pushrules_all::v3::Request>,
|
||||
) -> Result<RumaResponse<get_pushrules_all::v3::Response>> {
|
||||
) -> Result<Ra<get_pushrules_all::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event = services()
|
||||
|
|
@ -37,7 +37,7 @@ pub(crate) async fn get_pushrules_all_route(
|
|||
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
|
||||
.content;
|
||||
|
||||
Ok(RumaResponse(get_pushrules_all::v3::Response {
|
||||
Ok(Ra(get_pushrules_all::v3::Response {
|
||||
global: account_data.global,
|
||||
}))
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ pub(crate) async fn get_pushrules_all_route(
|
|||
/// Retrieves a single specified push rule for this user.
|
||||
pub(crate) async fn get_pushrule_route(
|
||||
body: Ruma<get_pushrule::v3::Request>,
|
||||
) -> Result<RumaResponse<get_pushrule::v3::Response>> {
|
||||
) -> Result<Ra<get_pushrule::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event = services()
|
||||
|
|
@ -72,7 +72,7 @@ pub(crate) async fn get_pushrule_route(
|
|||
.map(Into::into);
|
||||
|
||||
if let Some(rule) = rule {
|
||||
Ok(RumaResponse(get_pushrule::v3::Response {
|
||||
Ok(Ra(get_pushrule::v3::Response {
|
||||
rule,
|
||||
}))
|
||||
} else {
|
||||
|
|
@ -85,7 +85,7 @@ pub(crate) async fn get_pushrule_route(
|
|||
/// Creates a single specified push rule for this user.
|
||||
pub(crate) async fn set_pushrule_route(
|
||||
body: Ruma<set_pushrule::v3::Request>,
|
||||
) -> Result<RumaResponse<set_pushrule::v3::Response>> {
|
||||
) -> Result<Ra<set_pushrule::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let body = body.body;
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ pub(crate) async fn set_pushrule_route(
|
|||
.expect("to json value always works"),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(set_pushrule::v3::Response {}))
|
||||
Ok(Ra(set_pushrule::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
|
||||
|
|
@ -165,7 +165,7 @@ pub(crate) async fn set_pushrule_route(
|
|||
/// Gets the actions of a single specified push rule for this user.
|
||||
pub(crate) async fn get_pushrule_actions_route(
|
||||
body: Ruma<get_pushrule_actions::v3::Request>,
|
||||
) -> Result<RumaResponse<get_pushrule_actions::v3::Response>> {
|
||||
) -> Result<Ra<get_pushrule_actions::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if body.scope != RuleScope::Global {
|
||||
|
|
@ -200,7 +200,7 @@ pub(crate) async fn get_pushrule_actions_route(
|
|||
"Push rule not found.",
|
||||
))?;
|
||||
|
||||
Ok(RumaResponse(get_pushrule_actions::v3::Response {
|
||||
Ok(Ra(get_pushrule_actions::v3::Response {
|
||||
actions,
|
||||
}))
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ pub(crate) async fn get_pushrule_actions_route(
|
|||
/// Sets the actions of a single specified push rule for this user.
|
||||
pub(crate) async fn set_pushrule_actions_route(
|
||||
body: Ruma<set_pushrule_actions::v3::Request>,
|
||||
) -> Result<RumaResponse<set_pushrule_actions::v3::Response>> {
|
||||
) -> Result<Ra<set_pushrule_actions::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if body.scope != RuleScope::Global {
|
||||
|
|
@ -257,7 +257,7 @@ pub(crate) async fn set_pushrule_actions_route(
|
|||
.expect("to json value always works"),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(set_pushrule_actions::v3::Response {}))
|
||||
Ok(Ra(set_pushrule_actions::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
||||
|
|
@ -265,7 +265,7 @@ pub(crate) async fn set_pushrule_actions_route(
|
|||
/// Gets the enabled status of a single specified push rule for this user.
|
||||
pub(crate) async fn get_pushrule_enabled_route(
|
||||
body: Ruma<get_pushrule_enabled::v3::Request>,
|
||||
) -> Result<RumaResponse<get_pushrule_enabled::v3::Response>> {
|
||||
) -> Result<Ra<get_pushrule_enabled::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if body.scope != RuleScope::Global {
|
||||
|
|
@ -301,7 +301,7 @@ pub(crate) async fn get_pushrule_enabled_route(
|
|||
"Push rule not found.",
|
||||
))?;
|
||||
|
||||
Ok(RumaResponse(get_pushrule_enabled::v3::Response {
|
||||
Ok(Ra(get_pushrule_enabled::v3::Response {
|
||||
enabled,
|
||||
}))
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ pub(crate) async fn get_pushrule_enabled_route(
|
|||
/// Sets the enabled status of a single specified push rule for this user.
|
||||
pub(crate) async fn set_pushrule_enabled_route(
|
||||
body: Ruma<set_pushrule_enabled::v3::Request>,
|
||||
) -> Result<RumaResponse<set_pushrule_enabled::v3::Response>> {
|
||||
) -> Result<Ra<set_pushrule_enabled::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if body.scope != RuleScope::Global {
|
||||
|
|
@ -358,7 +358,7 @@ pub(crate) async fn set_pushrule_enabled_route(
|
|||
.expect("to json value always works"),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(set_pushrule_enabled::v3::Response {}))
|
||||
Ok(Ra(set_pushrule_enabled::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `DELETE /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}`
|
||||
|
|
@ -366,7 +366,7 @@ pub(crate) async fn set_pushrule_enabled_route(
|
|||
/// Deletes a single specified push rule for this user.
|
||||
pub(crate) async fn delete_pushrule_route(
|
||||
body: Ruma<delete_pushrule::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_pushrule::v3::Response>> {
|
||||
) -> Result<Ra<delete_pushrule::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if body.scope != RuleScope::Global {
|
||||
|
|
@ -418,7 +418,7 @@ pub(crate) async fn delete_pushrule_route(
|
|||
.expect("to json value always works"),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(delete_pushrule::v3::Response {}))
|
||||
Ok(Ra(delete_pushrule::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/pushers`
|
||||
|
|
@ -426,10 +426,10 @@ pub(crate) async fn delete_pushrule_route(
|
|||
/// Gets all currently active pushers for the sender user.
|
||||
pub(crate) async fn get_pushers_route(
|
||||
body: Ruma<get_pushers::v3::Request>,
|
||||
) -> Result<RumaResponse<get_pushers::v3::Response>> {
|
||||
) -> Result<Ra<get_pushers::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
Ok(RumaResponse(get_pushers::v3::Response {
|
||||
Ok(Ra(get_pushers::v3::Response {
|
||||
pushers: services().pusher.get_pushers(sender_user)?,
|
||||
}))
|
||||
}
|
||||
|
|
@ -441,10 +441,10 @@ pub(crate) async fn get_pushers_route(
|
|||
/// - TODO: Handle `append`
|
||||
pub(crate) async fn set_pushers_route(
|
||||
body: Ruma<set_pusher::v3::Request>,
|
||||
) -> Result<RumaResponse<set_pusher::v3::Response>> {
|
||||
) -> Result<Ra<set_pusher::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
services().pusher.set_pusher(sender_user, body.action.clone())?;
|
||||
|
||||
Ok(RumaResponse(set_pusher::v3::Response::default()))
|
||||
Ok(Ra(set_pusher::v3::Response::default()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ use ruma::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
service::rooms::timeline::PduCount, services, Error, Result, Ruma,
|
||||
RumaResponse,
|
||||
service::rooms::timeline::PduCount, services, Error, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers`
|
||||
|
|
@ -25,7 +24,7 @@ use crate::{
|
|||
/// EDU
|
||||
pub(crate) async fn set_read_marker_route(
|
||||
body: Ruma<set_read_marker::v3::Request>,
|
||||
) -> Result<RumaResponse<set_read_marker::v3::Response>> {
|
||||
) -> Result<Ra<set_read_marker::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if let Some(fully_read) = &body.fully_read {
|
||||
|
|
@ -98,7 +97,7 @@ pub(crate) async fn set_read_marker_route(
|
|||
)?;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(set_read_marker::v3::Response {}))
|
||||
Ok(Ra(set_read_marker::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}`
|
||||
|
|
@ -106,7 +105,7 @@ pub(crate) async fn set_read_marker_route(
|
|||
/// Sets private read marker and public read receipt EDU.
|
||||
pub(crate) async fn create_receipt_route(
|
||||
body: Ruma<create_receipt::v3::Request>,
|
||||
) -> Result<RumaResponse<create_receipt::v3::Response>> {
|
||||
) -> Result<Ra<create_receipt::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if matches!(
|
||||
|
|
@ -188,5 +187,5 @@ pub(crate) async fn create_receipt_route(
|
|||
_ => return Err(Error::bad_database("Unsupported receipt type")),
|
||||
}
|
||||
|
||||
Ok(RumaResponse(create_receipt::v3::Response {}))
|
||||
Ok(Ra(create_receipt::v3::Response {}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use ruma::{
|
|||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
|
||||
use crate::{service::pdu::PduBuilder, services, Result, Ruma, RumaResponse};
|
||||
use crate::{service::pdu::PduBuilder, services, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}`
|
||||
///
|
||||
|
|
@ -15,7 +15,7 @@ use crate::{service::pdu::PduBuilder, services, Result, Ruma, RumaResponse};
|
|||
/// - TODO: Handle txn id
|
||||
pub(crate) async fn redact_event_route(
|
||||
body: Ruma<redact_event::v3::Request>,
|
||||
) -> Result<RumaResponse<redact_event::v3::Response>> {
|
||||
) -> Result<Ra<redact_event::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let body = body.body;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ pub(crate) async fn redact_event_route(
|
|||
drop(state_lock);
|
||||
|
||||
let event_id = (*event_id).to_owned();
|
||||
Ok(RumaResponse(redact_event::v3::Response {
|
||||
Ok(Ra(redact_event::v3::Response {
|
||||
event_id,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,18 +6,13 @@ use ruma::{
|
|||
uint,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
service::rooms::timeline::PduCount, services, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{service::rooms::timeline::PduCount, services, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}`
|
||||
pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(
|
||||
body: Ruma<get_relating_events_with_rel_type_and_event_type::v1::Request>,
|
||||
) -> Result<
|
||||
RumaResponse<
|
||||
get_relating_events_with_rel_type_and_event_type::v1::Response,
|
||||
>,
|
||||
> {
|
||||
) -> Result<Ra<get_relating_events_with_rel_type_and_event_type::v1::Response>>
|
||||
{
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let from = match body.from.clone() {
|
||||
|
|
@ -50,19 +45,17 @@ pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route(
|
|||
limit,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(
|
||||
get_relating_events_with_rel_type_and_event_type::v1::Response {
|
||||
Ok(Ra(get_relating_events_with_rel_type_and_event_type::v1::Response {
|
||||
chunk: res.chunk,
|
||||
next_batch: res.next_batch,
|
||||
prev_batch: res.prev_batch,
|
||||
},
|
||||
))
|
||||
}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}`
|
||||
pub(crate) async fn get_relating_events_with_rel_type_route(
|
||||
body: Ruma<get_relating_events_with_rel_type::v1::Request>,
|
||||
) -> Result<RumaResponse<get_relating_events_with_rel_type::v1::Response>> {
|
||||
) -> Result<Ra<get_relating_events_with_rel_type::v1::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let from = match body.from.clone() {
|
||||
|
|
@ -95,7 +88,7 @@ pub(crate) async fn get_relating_events_with_rel_type_route(
|
|||
limit,
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(get_relating_events_with_rel_type::v1::Response {
|
||||
Ok(Ra(get_relating_events_with_rel_type::v1::Response {
|
||||
chunk: res.chunk,
|
||||
next_batch: res.next_batch,
|
||||
prev_batch: res.prev_batch,
|
||||
|
|
@ -105,7 +98,7 @@ pub(crate) async fn get_relating_events_with_rel_type_route(
|
|||
/// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}`
|
||||
pub(crate) async fn get_relating_events_route(
|
||||
body: Ruma<get_relating_events::v1::Request>,
|
||||
) -> Result<RumaResponse<get_relating_events::v1::Response>> {
|
||||
) -> Result<Ra<get_relating_events::v1::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let from = match body.from.clone() {
|
||||
|
|
@ -140,5 +133,5 @@ pub(crate) async fn get_relating_events_route(
|
|||
to,
|
||||
limit,
|
||||
)
|
||||
.map(RumaResponse)
|
||||
.map(Ra)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ use ruma::{
|
|||
int,
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}`
|
||||
///
|
||||
/// Reports an inappropriate event to homeserver admins
|
||||
pub(crate) async fn report_event_route(
|
||||
body: Ruma<report_content::v3::Request>,
|
||||
) -> Result<RumaResponse<report_content::v3::Response>> {
|
||||
) -> Result<Ra<report_content::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let Some(pdu) = services().rooms.timeline.get_pdu(&body.event_id)? else {
|
||||
|
|
@ -91,5 +91,5 @@ pub(crate) async fn report_event_route(
|
|||
),
|
||||
));
|
||||
|
||||
Ok(RumaResponse(report_content::v3::Response {}))
|
||||
Ok(Ra(report_content::v3::Response {}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use tracing::{info, warn};
|
|||
|
||||
use crate::{
|
||||
api::client_server::invite_helper, service::pdu::PduBuilder, services,
|
||||
Error, Result, Ruma, RumaResponse,
|
||||
Error, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `POST /_matrix/client/r0/createRoom`
|
||||
|
|
@ -53,7 +53,7 @@ use crate::{
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn create_room_route(
|
||||
body: Ruma<create_room::v3::Request>,
|
||||
) -> Result<RumaResponse<create_room::v3::Response>> {
|
||||
) -> Result<Ra<create_room::v3::Response>> {
|
||||
use create_room::v3::RoomPreset;
|
||||
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
@ -538,7 +538,7 @@ pub(crate) async fn create_room_route(
|
|||
|
||||
info!("{} created a room", sender_user);
|
||||
|
||||
Ok(RumaResponse(create_room::v3::Response::new(room_id)))
|
||||
Ok(Ra(create_room::v3::Response::new(room_id)))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}`
|
||||
|
|
@ -549,7 +549,7 @@ pub(crate) async fn create_room_route(
|
|||
/// visibility)
|
||||
pub(crate) async fn get_room_event_route(
|
||||
body: Ruma<get_room_event::v3::Request>,
|
||||
) -> Result<RumaResponse<get_room_event::v3::Response>> {
|
||||
) -> Result<Ra<get_room_event::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event = services().rooms.timeline.get_pdu(&body.event_id)?.ok_or_else(
|
||||
|
|
@ -573,7 +573,7 @@ pub(crate) async fn get_room_event_route(
|
|||
let mut event = (*event).clone();
|
||||
event.add_age()?;
|
||||
|
||||
Ok(RumaResponse(get_room_event::v3::Response {
|
||||
Ok(Ra(get_room_event::v3::Response {
|
||||
event: event.to_room_event(),
|
||||
}))
|
||||
}
|
||||
|
|
@ -586,7 +586,7 @@ pub(crate) async fn get_room_event_route(
|
|||
/// user to call it if `history_visibility` is world readable
|
||||
pub(crate) async fn get_room_aliases_route(
|
||||
body: Ruma<aliases::v3::Request>,
|
||||
) -> Result<RumaResponse<aliases::v3::Response>> {
|
||||
) -> Result<Ra<aliases::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services().rooms.state_cache.is_joined(sender_user, &body.room_id)? {
|
||||
|
|
@ -596,7 +596,7 @@ pub(crate) async fn get_room_aliases_route(
|
|||
));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(aliases::v3::Response {
|
||||
Ok(Ra(aliases::v3::Response {
|
||||
aliases: services()
|
||||
.rooms
|
||||
.alias
|
||||
|
|
@ -619,7 +619,7 @@ pub(crate) async fn get_room_aliases_route(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn upgrade_room_route(
|
||||
body: Ruma<upgrade_room::v3::Request>,
|
||||
) -> Result<RumaResponse<upgrade_room::v3::Response>> {
|
||||
) -> Result<Ra<upgrade_room::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services().globals.supported_room_versions().contains(&body.new_version)
|
||||
|
|
@ -914,7 +914,7 @@ pub(crate) async fn upgrade_room_route(
|
|||
drop(state_lock);
|
||||
|
||||
// Return the replacement room id
|
||||
Ok(RumaResponse(upgrade_room::v3::Response {
|
||||
Ok(Ra(upgrade_room::v3::Response {
|
||||
replacement_room,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use ruma::{
|
|||
uint,
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/search`
|
||||
///
|
||||
|
|
@ -25,7 +25,7 @@ use crate::{services, Error, Result, Ruma, RumaResponse};
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn search_events_route(
|
||||
body: Ruma<search_events::v3::Request>,
|
||||
) -> Result<RumaResponse<search_events::v3::Response>> {
|
||||
) -> Result<Ra<search_events::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let search_criteria = body.search_categories.room_events.as_ref().unwrap();
|
||||
|
|
@ -136,7 +136,7 @@ pub(crate) async fn search_events_route(
|
|||
Some((skip + limit).to_string())
|
||||
};
|
||||
|
||||
Ok(RumaResponse(search_events::v3::Response::new(ResultCategories {
|
||||
Ok(Ra(search_events::v3::Response::new(ResultCategories {
|
||||
room_events: ResultRoomEvents {
|
||||
count: None,
|
||||
// TODO
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use serde::Deserialize;
|
|||
use tracing::{info, warn};
|
||||
|
||||
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||
use crate::{services, utils, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, utils, Error, Ra, Result, Ruma};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct Claims {
|
||||
|
|
@ -29,8 +29,8 @@ struct Claims {
|
|||
/// the `type` field when logging in.
|
||||
pub(crate) async fn get_login_types_route(
|
||||
_body: Ruma<get_login_types::v3::Request>,
|
||||
) -> Result<RumaResponse<get_login_types::v3::Response>> {
|
||||
Ok(RumaResponse(get_login_types::v3::Response::new(vec![
|
||||
) -> Result<Ra<get_login_types::v3::Response>> {
|
||||
Ok(Ra(get_login_types::v3::Response::new(vec![
|
||||
get_login_types::v3::LoginType::Password(PasswordLoginType::default()),
|
||||
get_login_types::v3::LoginType::ApplicationService(
|
||||
ApplicationServiceLoginType::default(),
|
||||
|
|
@ -54,7 +54,7 @@ pub(crate) async fn get_login_types_route(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn login_route(
|
||||
body: Ruma<login::v3::Request>,
|
||||
) -> Result<RumaResponse<login::v3::Response>> {
|
||||
) -> Result<Ra<login::v3::Response>> {
|
||||
// To allow deprecated login methods
|
||||
#![allow(deprecated)]
|
||||
// Validate login method
|
||||
|
|
@ -256,7 +256,7 @@ pub(crate) async fn login_route(
|
|||
|
||||
// Homeservers are still required to send the `home_server` field
|
||||
#[allow(deprecated)]
|
||||
Ok(RumaResponse(login::v3::Response {
|
||||
Ok(Ra(login::v3::Response {
|
||||
user_id,
|
||||
access_token: token,
|
||||
home_server: Some(services().globals.server_name().to_owned()),
|
||||
|
|
@ -278,7 +278,7 @@ pub(crate) async fn login_route(
|
|||
/// - Triggers device list updates
|
||||
pub(crate) async fn logout_route(
|
||||
body: Ruma<logout::v3::Request>,
|
||||
) -> Result<RumaResponse<logout::v3::Response>> {
|
||||
) -> Result<Ra<logout::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");
|
||||
|
|
@ -294,7 +294,7 @@ pub(crate) async fn logout_route(
|
|||
|
||||
services().users.remove_device(sender_user, sender_device)?;
|
||||
|
||||
Ok(RumaResponse(logout::v3::Response::new()))
|
||||
Ok(Ra(logout::v3::Response::new()))
|
||||
}
|
||||
|
||||
/// # `POST /_matrix/client/r0/logout/all`
|
||||
|
|
@ -311,7 +311,7 @@ pub(crate) async fn logout_route(
|
|||
/// /_matrix/client/r0/logout`](logout_route) from each device of this user.
|
||||
pub(crate) async fn logout_all_route(
|
||||
body: Ruma<logout_all::v3::Request>,
|
||||
) -> Result<RumaResponse<logout_all::v3::Response>> {
|
||||
) -> Result<Ra<logout_all::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if let Some(info) = &body.appservice_info {
|
||||
|
|
@ -332,5 +332,5 @@ pub(crate) async fn logout_all_route(
|
|||
services().users.remove_device(sender_user, &device_id)?;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(logout_all::v3::Response::new()))
|
||||
Ok(Ra(logout_all::v3::Response::new()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use ruma::{api::client::space::get_hierarchy, uint};
|
||||
|
||||
use crate::{services, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/v1/rooms/{room_id}/hierarchy`
|
||||
///
|
||||
|
|
@ -8,7 +8,7 @@ use crate::{services, Result, Ruma, RumaResponse};
|
|||
/// of a given space.
|
||||
pub(crate) async fn get_hierarchy_route(
|
||||
body: Ruma<get_hierarchy::v1::Request>,
|
||||
) -> Result<RumaResponse<get_hierarchy::v1::Response>> {
|
||||
) -> Result<Ra<get_hierarchy::v1::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let skip =
|
||||
|
|
@ -40,5 +40,5 @@ pub(crate) async fn get_hierarchy_route(
|
|||
body.suggested_only,
|
||||
)
|
||||
.await
|
||||
.map(RumaResponse)
|
||||
.map(Ra)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ use ruma::{
|
|||
};
|
||||
use tracing::log::warn;
|
||||
|
||||
use crate::{
|
||||
service::pdu::PduBuilder, services, Error, Result, Ruma, RumaResponse,
|
||||
};
|
||||
use crate::{service::pdu::PduBuilder, services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}`
|
||||
///
|
||||
|
|
@ -28,7 +26,7 @@ use crate::{
|
|||
/// - If event is new `canonical_alias`: Rejects if alias is incorrect
|
||||
pub(crate) async fn send_state_event_for_key_route(
|
||||
body: Ruma<send_state_event::v3::Request>,
|
||||
) -> Result<RumaResponse<send_state_event::v3::Response>> {
|
||||
) -> Result<Ra<send_state_event::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event_id = send_state_event_for_key_helper(
|
||||
|
|
@ -42,7 +40,7 @@ pub(crate) async fn send_state_event_for_key_route(
|
|||
.await?;
|
||||
|
||||
let event_id = (*event_id).to_owned();
|
||||
Ok(RumaResponse(send_state_event::v3::Response {
|
||||
Ok(Ra(send_state_event::v3::Response {
|
||||
event_id,
|
||||
}))
|
||||
}
|
||||
|
|
@ -57,7 +55,7 @@ pub(crate) async fn send_state_event_for_key_route(
|
|||
/// - If event is new `canonical_alias`: Rejects if alias is incorrect
|
||||
pub(crate) async fn send_state_event_for_empty_key_route(
|
||||
body: Ruma<send_state_event::v3::Request>,
|
||||
) -> Result<RumaResponse<send_state_event::v3::Response>> {
|
||||
) -> Result<Ra<send_state_event::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
// Forbid m.room.encryption if encryption is disabled
|
||||
|
|
@ -94,7 +92,7 @@ pub(crate) async fn send_state_event_for_empty_key_route(
|
|||
/// readable
|
||||
pub(crate) async fn get_state_events_route(
|
||||
body: Ruma<get_state_events::v3::Request>,
|
||||
) -> Result<RumaResponse<get_state_events::v3::Response>> {
|
||||
) -> Result<Ra<get_state_events::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services()
|
||||
|
|
@ -108,7 +106,7 @@ pub(crate) async fn get_state_events_route(
|
|||
));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_state_events::v3::Response {
|
||||
Ok(Ra(get_state_events::v3::Response {
|
||||
room_state: services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
|
|
@ -128,7 +126,7 @@ pub(crate) async fn get_state_events_route(
|
|||
/// readable
|
||||
pub(crate) async fn get_state_events_for_key_route(
|
||||
body: Ruma<get_state_events_for_key::v3::Request>,
|
||||
) -> Result<RumaResponse<get_state_events_for_key::v3::Response>> {
|
||||
) -> Result<Ra<get_state_events_for_key::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services()
|
||||
|
|
@ -154,7 +152,7 @@ pub(crate) async fn get_state_events_for_key_route(
|
|||
Error::BadRequest(ErrorKind::NotFound, "State event not found.")
|
||||
})?;
|
||||
|
||||
Ok(RumaResponse(get_state_events_for_key::v3::Response {
|
||||
Ok(Ra(get_state_events_for_key::v3::Response {
|
||||
content: serde_json::from_str(event.content.get()).map_err(|_| {
|
||||
Error::bad_database("Invalid event content in database")
|
||||
})?,
|
||||
|
|
@ -169,7 +167,7 @@ pub(crate) async fn get_state_events_for_key_route(
|
|||
/// readable
|
||||
pub(crate) async fn get_state_events_for_empty_key_route(
|
||||
body: Ruma<get_state_events_for_key::v3::Request>,
|
||||
) -> Result<RumaResponse<get_state_events_for_key::v3::Response>> {
|
||||
) -> Result<Ra<get_state_events_for_key::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !services()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use tracing::{debug, error};
|
|||
|
||||
use crate::{
|
||||
service::{pdu::EventHash, rooms::timeline::PduCount},
|
||||
services, utils, Error, PduEvent, Result, Ruma, RumaResponse,
|
||||
services, utils, Error, PduEvent, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
/// # `GET /_matrix/client/r0/sync`
|
||||
|
|
@ -74,8 +74,7 @@ use crate::{
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn sync_events_route(
|
||||
body: Ruma<sync_events::v3::Request>,
|
||||
) -> Result<RumaResponse<sync_events::v3::Response>, RumaResponse<UiaaResponse>>
|
||||
{
|
||||
) -> Result<Ra<sync_events::v3::Response>, Ra<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;
|
||||
|
|
@ -458,10 +457,10 @@ pub(crate) async fn sync_events_route(
|
|||
Ok(x) => x.expect("watcher should succeed"),
|
||||
Err(error) => debug!(%error, "timed out"),
|
||||
};
|
||||
Ok(RumaResponse(response))
|
||||
Ok(Ra(response))
|
||||
} else {
|
||||
// Only cache if we made progress
|
||||
Ok(RumaResponse(response))
|
||||
Ok(Ra(response))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1128,8 +1127,7 @@ fn share_encrypted_room(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn sync_events_v4_route(
|
||||
body: Ruma<sync_events::v4::Request>,
|
||||
) -> Result<RumaResponse<sync_events::v4::Response>, RumaResponse<UiaaResponse>>
|
||||
{
|
||||
) -> Result<Ra<sync_events::v4::Response>, Ra<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;
|
||||
|
|
@ -1702,7 +1700,7 @@ pub(crate) async fn sync_events_v4_route(
|
|||
};
|
||||
}
|
||||
|
||||
Ok(RumaResponse(sync_events::v4::Response {
|
||||
Ok(Ra(sync_events::v4::Response {
|
||||
initial: globalsince == 0,
|
||||
txn_id: body.txn_id.clone(),
|
||||
pos: next_batch.to_string(),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use ruma::{
|
|||
},
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
|
||||
///
|
||||
|
|
@ -17,7 +17,7 @@ use crate::{services, Error, Result, Ruma, RumaResponse};
|
|||
/// - Inserts the tag into the tag event of the room account data.
|
||||
pub(crate) async fn update_tag_route(
|
||||
body: Ruma<create_tag::v3::Request>,
|
||||
) -> Result<RumaResponse<create_tag::v3::Response>> {
|
||||
) -> Result<Ra<create_tag::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event = services().account_data.get(
|
||||
|
|
@ -53,7 +53,7 @@ pub(crate) async fn update_tag_route(
|
|||
&serde_json::to_value(tags_event).expect("to json value always works"),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(create_tag::v3::Response {}))
|
||||
Ok(Ra(create_tag::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}`
|
||||
|
|
@ -63,7 +63,7 @@ pub(crate) async fn update_tag_route(
|
|||
/// - Removes the tag from the tag event of the room account data.
|
||||
pub(crate) async fn delete_tag_route(
|
||||
body: Ruma<delete_tag::v3::Request>,
|
||||
) -> Result<RumaResponse<delete_tag::v3::Response>> {
|
||||
) -> Result<Ra<delete_tag::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event = services().account_data.get(
|
||||
|
|
@ -96,7 +96,7 @@ pub(crate) async fn delete_tag_route(
|
|||
&serde_json::to_value(tags_event).expect("to json value always works"),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(delete_tag::v3::Response {}))
|
||||
Ok(Ra(delete_tag::v3::Response {}))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags`
|
||||
|
|
@ -106,7 +106,7 @@ pub(crate) async fn delete_tag_route(
|
|||
/// - Gets the tag event of the room account data.
|
||||
pub(crate) async fn get_tags_route(
|
||||
body: Ruma<get_tags::v3::Request>,
|
||||
) -> Result<RumaResponse<get_tags::v3::Response>> {
|
||||
) -> Result<Ra<get_tags::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let event = services().account_data.get(
|
||||
|
|
@ -130,7 +130,7 @@ pub(crate) async fn get_tags_route(
|
|||
},
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(get_tags::v3::Response {
|
||||
Ok(Ra(get_tags::v3::Response {
|
||||
tags: tags_event.content.tags,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@ use std::collections::BTreeMap;
|
|||
|
||||
use ruma::api::client::thirdparty::get_protocols;
|
||||
|
||||
use crate::{Result, Ruma, RumaResponse};
|
||||
use crate::{Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/thirdparty/protocols`
|
||||
///
|
||||
/// TODO: Fetches all metadata about protocols supported by the homeserver.
|
||||
pub(crate) async fn get_protocols_route(
|
||||
_body: Ruma<get_protocols::v3::Request>,
|
||||
) -> Result<RumaResponse<get_protocols::v3::Response>> {
|
||||
) -> Result<Ra<get_protocols::v3::Response>> {
|
||||
// TODO
|
||||
Ok(RumaResponse(get_protocols::v3::Response {
|
||||
Ok(Ra(get_protocols::v3::Response {
|
||||
protocols: BTreeMap::new(),
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use ruma::api::client::{error::ErrorKind, threads::get_threads};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/threads`
|
||||
pub(crate) async fn get_threads_route(
|
||||
body: Ruma<get_threads::v1::Request>,
|
||||
) -> Result<RumaResponse<get_threads::v1::Response>> {
|
||||
) -> Result<Ra<get_threads::v1::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
// Use limit or else 10, with maximum 100
|
||||
|
|
@ -36,7 +36,7 @@ pub(crate) async fn get_threads_route(
|
|||
|
||||
let next_batch = threads.last().map(|(count, _)| count.to_string());
|
||||
|
||||
Ok(RumaResponse(get_threads::v1::Response {
|
||||
Ok(Ra(get_threads::v1::Response {
|
||||
chunk: threads
|
||||
.into_iter()
|
||||
.map(|(_, pdu)| pdu.to_room_event())
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ use ruma::{
|
|||
to_device::DeviceIdOrAllDevices,
|
||||
};
|
||||
|
||||
use crate::{services, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}`
|
||||
///
|
||||
/// Send a to-device event to a set of client devices.
|
||||
pub(crate) async fn send_event_to_device_route(
|
||||
body: Ruma<send_event_to_device::v3::Request>,
|
||||
) -> Result<RumaResponse<send_event_to_device::v3::Response>> {
|
||||
) -> Result<Ra<send_event_to_device::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device = body.sender_device.as_deref();
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ pub(crate) async fn send_event_to_device_route(
|
|||
.existing_txnid(sender_user, sender_device, &body.txn_id)?
|
||||
.is_some()
|
||||
{
|
||||
return Ok(RumaResponse(send_event_to_device::v3::Response {}));
|
||||
return Ok(Ra(send_event_to_device::v3::Response {}));
|
||||
}
|
||||
|
||||
for (target_user_id, map) in &body.messages {
|
||||
|
|
@ -103,5 +103,5 @@ pub(crate) async fn send_event_to_device_route(
|
|||
&[],
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(send_event_to_device::v3::Response {}))
|
||||
Ok(Ra(send_event_to_device::v3::Response {}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use ruma::api::client::{error::ErrorKind, typing::create_typing_event};
|
||||
|
||||
use crate::{services, utils, Error, Result, Ruma, RumaResponse};
|
||||
use crate::{services, utils, Error, Ra, Result, Ruma};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
|
||||
///
|
||||
/// Sets the typing state of the sender user.
|
||||
pub(crate) async fn create_typing_event_route(
|
||||
body: Ruma<create_typing_event::v3::Request>,
|
||||
) -> Result<RumaResponse<create_typing_event::v3::Response>> {
|
||||
) -> Result<Ra<create_typing_event::v3::Response>> {
|
||||
use create_typing_event::v3::Typing;
|
||||
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
|
@ -40,5 +40,5 @@ pub(crate) async fn create_typing_event_route(
|
|||
.await?;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(create_typing_event::v3::Response {}))
|
||||
Ok(Ra(create_typing_event::v3::Response {}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::{collections::BTreeMap, iter::FromIterator};
|
|||
|
||||
use ruma::api::client::discovery::get_supported_versions;
|
||||
|
||||
use crate::{Result, Ruma, RumaResponse};
|
||||
use crate::{Ra, Result, Ruma};
|
||||
|
||||
/// # `GET /_matrix/client/versions`
|
||||
///
|
||||
|
|
@ -18,7 +18,7 @@ use crate::{Result, Ruma, RumaResponse};
|
|||
/// should avoid using unstable features in their stable releases
|
||||
pub(crate) async fn get_supported_versions_route(
|
||||
_body: Ruma<get_supported_versions::Request>,
|
||||
) -> Result<RumaResponse<get_supported_versions::Response>> {
|
||||
) -> Result<Ra<get_supported_versions::Response>> {
|
||||
let resp = get_supported_versions::Response {
|
||||
versions: vec![
|
||||
"r0.5.0".to_owned(),
|
||||
|
|
@ -35,5 +35,5 @@ pub(crate) async fn get_supported_versions_route(
|
|||
)]),
|
||||
};
|
||||
|
||||
Ok(RumaResponse(resp))
|
||||
Ok(Ra(resp))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use ruma::{
|
|||
},
|
||||
};
|
||||
|
||||
use crate::{services, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Ra, Result, Ruma};
|
||||
|
||||
/// # `POST /_matrix/client/r0/user_directory/search`
|
||||
///
|
||||
|
|
@ -17,7 +17,7 @@ use crate::{services, Result, Ruma, RumaResponse};
|
|||
/// and don't share a room with the sender
|
||||
pub(crate) async fn search_users_route(
|
||||
body: Ruma<search_users::v3::Request>,
|
||||
) -> Result<RumaResponse<search_users::v3::Response>> {
|
||||
) -> Result<Ra<search_users::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let limit = body.limit.try_into().unwrap_or(usize::MAX);
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ pub(crate) async fn search_users_route(
|
|||
let results = users.by_ref().take(limit).collect();
|
||||
let limited = users.next().is_some();
|
||||
|
||||
Ok(RumaResponse(search_users::v3::Response {
|
||||
Ok(Ra(search_users::v3::Response {
|
||||
results,
|
||||
limited,
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use hmac::{Hmac, Mac};
|
|||
use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch};
|
||||
use sha1::Sha1;
|
||||
|
||||
use crate::{services, Result, Ruma, RumaResponse};
|
||||
use crate::{services, Ra, Result, Ruma};
|
||||
|
||||
type HmacSha1 = Hmac<Sha1>;
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ type HmacSha1 = Hmac<Sha1>;
|
|||
/// TODO: Returns information about the recommended turn server.
|
||||
pub(crate) async fn turn_server_route(
|
||||
body: Ruma<get_turn_server_info::v3::Request>,
|
||||
) -> Result<RumaResponse<get_turn_server_info::v3::Response>> {
|
||||
) -> Result<Ra<get_turn_server_info::v3::Response>> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let turn_secret = services().globals.turn_secret().clone();
|
||||
|
|
@ -43,7 +43,7 @@ pub(crate) async fn turn_server_route(
|
|||
(username, password)
|
||||
};
|
||||
|
||||
Ok(RumaResponse(get_turn_server_info::v3::Response {
|
||||
Ok(Ra(get_turn_server_info::v3::Response {
|
||||
username,
|
||||
password,
|
||||
uris: services().globals.turn_uris().to_vec(),
|
||||
|
|
|
|||
|
|
@ -28,16 +28,20 @@ impl<T> Deref for Ruma<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// A wrapper to convert Ruma data to an Axum response
|
||||
///
|
||||
/// Named so because this converts from **R**uma to **A**xum. See also [`Ruma`],
|
||||
/// which is roughly the inverse of this type.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct RumaResponse<T>(pub(crate) T);
|
||||
pub(crate) struct Ra<T>(pub(crate) T);
|
||||
|
||||
impl<T> From<T> for RumaResponse<T> {
|
||||
impl<T> From<T> for Ra<T> {
|
||||
fn from(t: T) -> Self {
|
||||
Self(t)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Error> for RumaResponse<UiaaResponse> {
|
||||
impl From<Error> for Ra<UiaaResponse> {
|
||||
fn from(t: Error) -> Self {
|
||||
t.to_response()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use ruma::{
|
|||
use serde::Deserialize;
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use super::{Ruma, RumaResponse};
|
||||
use super::{Ra, Ruma};
|
||||
use crate::{service::appservice::RegistrationInfo, services, Error, Result};
|
||||
|
||||
enum Token {
|
||||
|
|
@ -450,7 +450,7 @@ impl Credentials for XMatrix {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: OutgoingResponse> IntoResponse for RumaResponse<T> {
|
||||
impl<T: OutgoingResponse> IntoResponse for Ra<T> {
|
||||
fn into_response(self) -> Response {
|
||||
match self.0.try_into_http_response::<BytesMut>() {
|
||||
Ok(res) => res.map(BytesMut::freeze).map(Full::new).into_response(),
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ use tracing::{debug, error, warn};
|
|||
use crate::{
|
||||
api::client_server::{self, claim_keys_helper, get_keys_helper},
|
||||
service::pdu::{gen_event_id_canonical_json, PduBuilder},
|
||||
services, utils, Error, PduEvent, Result, Ruma, RumaResponse,
|
||||
services, utils, Error, PduEvent, Ra, Result, Ruma,
|
||||
};
|
||||
|
||||
/// Wraps either an literal IP address plus port, or a hostname plus complement
|
||||
|
|
@ -554,8 +554,8 @@ async fn request_well_known(destination: &str) -> Option<String> {
|
|||
/// Get version information on this server.
|
||||
pub(crate) async fn get_server_version_route(
|
||||
_body: Ruma<get_server_version::v1::Request>,
|
||||
) -> Result<RumaResponse<get_server_version::v1::Response>> {
|
||||
Ok(RumaResponse(get_server_version::v1::Response {
|
||||
) -> Result<Ra<get_server_version::v1::Response>> {
|
||||
Ok(Ra(get_server_version::v1::Response {
|
||||
server: Some(get_server_version::v1::Server {
|
||||
name: Some(env!("CARGO_PKG_NAME").to_owned()),
|
||||
version: Some(crate::version()),
|
||||
|
|
@ -631,7 +631,7 @@ pub(crate) async fn get_server_keys_deprecated_route() -> impl IntoResponse {
|
|||
/// Lists the public rooms on this server.
|
||||
pub(crate) async fn get_public_rooms_filtered_route(
|
||||
body: Ruma<get_public_rooms_filtered::v1::Request>,
|
||||
) -> Result<RumaResponse<get_public_rooms_filtered::v1::Response>> {
|
||||
) -> Result<Ra<get_public_rooms_filtered::v1::Response>> {
|
||||
let response = client_server::get_public_rooms_filtered_helper(
|
||||
None,
|
||||
body.limit,
|
||||
|
|
@ -641,7 +641,7 @@ pub(crate) async fn get_public_rooms_filtered_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_public_rooms_filtered::v1::Response {
|
||||
Ok(Ra(get_public_rooms_filtered::v1::Response {
|
||||
chunk: response.chunk,
|
||||
prev_batch: response.prev_batch,
|
||||
next_batch: response.next_batch,
|
||||
|
|
@ -654,7 +654,7 @@ pub(crate) async fn get_public_rooms_filtered_route(
|
|||
/// Lists the public rooms on this server.
|
||||
pub(crate) async fn get_public_rooms_route(
|
||||
body: Ruma<get_public_rooms::v1::Request>,
|
||||
) -> Result<RumaResponse<get_public_rooms::v1::Response>> {
|
||||
) -> Result<Ra<get_public_rooms::v1::Response>> {
|
||||
let response = client_server::get_public_rooms_filtered_helper(
|
||||
None,
|
||||
body.limit,
|
||||
|
|
@ -664,7 +664,7 @@ pub(crate) async fn get_public_rooms_route(
|
|||
)
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_public_rooms::v1::Response {
|
||||
Ok(Ra(get_public_rooms::v1::Response {
|
||||
chunk: response.chunk,
|
||||
prev_batch: response.prev_batch,
|
||||
next_batch: response.next_batch,
|
||||
|
|
@ -709,7 +709,7 @@ pub(crate) fn parse_incoming_pdu(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn send_transaction_message_route(
|
||||
body: Ruma<send_transaction_message::v1::Request>,
|
||||
) -> Result<RumaResponse<send_transaction_message::v1::Response>> {
|
||||
) -> Result<Ra<send_transaction_message::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -976,7 +976,7 @@ pub(crate) async fn send_transaction_message_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(send_transaction_message::v1::Response {
|
||||
Ok(Ra(send_transaction_message::v1::Response {
|
||||
pdus: resolved_map
|
||||
.into_iter()
|
||||
.map(|(e, r)| (e, r.map_err(|e| e.sanitized_error())))
|
||||
|
|
@ -992,7 +992,7 @@ pub(crate) async fn send_transaction_message_route(
|
|||
/// room
|
||||
pub(crate) async fn get_event_route(
|
||||
body: Ruma<get_event::v1::Request>,
|
||||
) -> Result<RumaResponse<get_event::v1::Response>> {
|
||||
) -> Result<Ra<get_event::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1035,7 +1035,7 @@ pub(crate) async fn get_event_route(
|
|||
));
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_event::v1::Response {
|
||||
Ok(Ra(get_event::v1::Response {
|
||||
origin: services().globals.server_name().to_owned(),
|
||||
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||
pdu: PduEvent::convert_to_outgoing_federation_event(event),
|
||||
|
|
@ -1048,7 +1048,7 @@ pub(crate) async fn get_event_route(
|
|||
/// history visibility allows.
|
||||
pub(crate) async fn get_backfill_route(
|
||||
body: Ruma<get_backfill::v1::Request>,
|
||||
) -> Result<RumaResponse<get_backfill::v1::Response>> {
|
||||
) -> Result<Ra<get_backfill::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1106,7 +1106,7 @@ pub(crate) async fn get_backfill_route(
|
|||
.map(PduEvent::convert_to_outgoing_federation_event)
|
||||
.collect();
|
||||
|
||||
Ok(RumaResponse(get_backfill::v1::Response {
|
||||
Ok(Ra(get_backfill::v1::Response {
|
||||
origin: services().globals.server_name().to_owned(),
|
||||
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
||||
pdus: events,
|
||||
|
|
@ -1118,7 +1118,7 @@ pub(crate) async fn get_backfill_route(
|
|||
/// Retrieves events that the sender is missing.
|
||||
pub(crate) async fn get_missing_events_route(
|
||||
body: Ruma<get_missing_events::v1::Request>,
|
||||
) -> Result<RumaResponse<get_missing_events::v1::Response>> {
|
||||
) -> Result<Ra<get_missing_events::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1208,7 +1208,7 @@ pub(crate) async fn get_missing_events_route(
|
|||
i += 1;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_missing_events::v1::Response {
|
||||
Ok(Ra(get_missing_events::v1::Response {
|
||||
events,
|
||||
}))
|
||||
}
|
||||
|
|
@ -1220,7 +1220,7 @@ pub(crate) async fn get_missing_events_route(
|
|||
/// - This does not include the event itself
|
||||
pub(crate) async fn get_event_authorization_route(
|
||||
body: Ruma<get_event_authorization::v1::Request>,
|
||||
) -> Result<RumaResponse<get_event_authorization::v1::Response>> {
|
||||
) -> Result<Ra<get_event_authorization::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1263,7 +1263,7 @@ pub(crate) async fn get_event_authorization_route(
|
|||
.get_auth_chain(room_id, vec![Arc::from(&*body.event_id)])
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_event_authorization::v1::Response {
|
||||
Ok(Ra(get_event_authorization::v1::Response {
|
||||
auth_chain: auth_chain_ids
|
||||
.filter_map(|id| {
|
||||
services().rooms.timeline.get_pdu_json(&id).ok()?
|
||||
|
|
@ -1278,7 +1278,7 @@ pub(crate) async fn get_event_authorization_route(
|
|||
/// Retrieves the current state of the room.
|
||||
pub(crate) async fn get_room_state_route(
|
||||
body: Ruma<get_room_state::v1::Request>,
|
||||
) -> Result<RumaResponse<get_room_state::v1::Response>> {
|
||||
) -> Result<Ra<get_room_state::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1326,7 +1326,7 @@ pub(crate) async fn get_room_state_route(
|
|||
.get_auth_chain(&body.room_id, vec![Arc::from(&*body.event_id)])
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_room_state::v1::Response {
|
||||
Ok(Ra(get_room_state::v1::Response {
|
||||
auth_chain: auth_chain_ids
|
||||
.filter_map(|id| {
|
||||
if let Some(json) =
|
||||
|
|
@ -1348,7 +1348,7 @@ pub(crate) async fn get_room_state_route(
|
|||
/// Retrieves the current state of the room.
|
||||
pub(crate) async fn get_room_state_ids_route(
|
||||
body: Ruma<get_room_state_ids::v1::Request>,
|
||||
) -> Result<RumaResponse<get_room_state_ids::v1::Response>> {
|
||||
) -> Result<Ra<get_room_state_ids::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1392,7 +1392,7 @@ pub(crate) async fn get_room_state_ids_route(
|
|||
.get_auth_chain(&body.room_id, vec![Arc::from(&*body.event_id)])
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_room_state_ids::v1::Response {
|
||||
Ok(Ra(get_room_state_ids::v1::Response {
|
||||
auth_chain_ids: auth_chain_ids.map(|id| (*id).to_owned()).collect(),
|
||||
pdu_ids,
|
||||
}))
|
||||
|
|
@ -1403,7 +1403,7 @@ pub(crate) async fn get_room_state_ids_route(
|
|||
/// Creates a join template.
|
||||
pub(crate) async fn create_join_event_template_route(
|
||||
body: Ruma<prepare_join_event::v1::Request>,
|
||||
) -> Result<RumaResponse<prepare_join_event::v1::Response>> {
|
||||
) -> Result<Ra<prepare_join_event::v1::Response>> {
|
||||
if !services().rooms.metadata.exists(&body.room_id)? {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::NotFound,
|
||||
|
|
@ -1504,7 +1504,7 @@ pub(crate) async fn create_join_event_template_route(
|
|||
|
||||
pdu_json.remove("event_id");
|
||||
|
||||
Ok(RumaResponse(prepare_join_event::v1::Response {
|
||||
Ok(Ra(prepare_join_event::v1::Response {
|
||||
room_version: Some(room_version_id),
|
||||
event: to_raw_value(&pdu_json)
|
||||
.expect("CanonicalJson can be serialized to JSON"),
|
||||
|
|
@ -1661,14 +1661,14 @@ async fn create_join_event(
|
|||
/// Submits a signed join event.
|
||||
pub(crate) async fn create_join_event_v1_route(
|
||||
body: Ruma<create_join_event::v1::Request>,
|
||||
) -> Result<RumaResponse<create_join_event::v1::Response>> {
|
||||
) -> Result<Ra<create_join_event::v1::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
let room_state =
|
||||
create_join_event(sender_servername, &body.room_id, &body.pdu).await?;
|
||||
|
||||
Ok(RumaResponse(create_join_event::v1::Response {
|
||||
Ok(Ra(create_join_event::v1::Response {
|
||||
room_state,
|
||||
}))
|
||||
}
|
||||
|
|
@ -1678,7 +1678,7 @@ pub(crate) async fn create_join_event_v1_route(
|
|||
/// Submits a signed join event.
|
||||
pub(crate) async fn create_join_event_v2_route(
|
||||
body: Ruma<create_join_event::v2::Request>,
|
||||
) -> Result<RumaResponse<create_join_event::v2::Response>> {
|
||||
) -> Result<Ra<create_join_event::v2::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1695,7 +1695,7 @@ pub(crate) async fn create_join_event_v2_route(
|
|||
servers_in_room: None,
|
||||
};
|
||||
|
||||
Ok(RumaResponse(create_join_event::v2::Response {
|
||||
Ok(Ra(create_join_event::v2::Response {
|
||||
room_state,
|
||||
}))
|
||||
}
|
||||
|
|
@ -1706,7 +1706,7 @@ pub(crate) async fn create_join_event_v2_route(
|
|||
#[allow(clippy::too_many_lines)]
|
||||
pub(crate) async fn create_invite_route(
|
||||
body: Ruma<create_invite::v2::Request>,
|
||||
) -> Result<RumaResponse<create_invite::v2::Response>> {
|
||||
) -> Result<Ra<create_invite::v2::Response>> {
|
||||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
|
|
@ -1827,7 +1827,7 @@ pub(crate) async fn create_invite_route(
|
|||
)?;
|
||||
}
|
||||
|
||||
Ok(RumaResponse(create_invite::v2::Response {
|
||||
Ok(Ra(create_invite::v2::Response {
|
||||
event: PduEvent::convert_to_outgoing_federation_event(signed_event),
|
||||
}))
|
||||
}
|
||||
|
|
@ -1837,7 +1837,7 @@ pub(crate) async fn create_invite_route(
|
|||
/// Gets information on all devices of the user.
|
||||
pub(crate) async fn get_devices_route(
|
||||
body: Ruma<get_devices::v1::Request>,
|
||||
) -> Result<RumaResponse<get_devices::v1::Response>> {
|
||||
) -> Result<Ra<get_devices::v1::Response>> {
|
||||
if body.user_id.server_name() != services().globals.server_name() {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
|
|
@ -1848,7 +1848,7 @@ pub(crate) async fn get_devices_route(
|
|||
let sender_servername =
|
||||
body.sender_servername.as_ref().expect("server is authenticated");
|
||||
|
||||
Ok(RumaResponse(get_devices::v1::Response {
|
||||
Ok(Ra(get_devices::v1::Response {
|
||||
user_id: body.user_id.clone(),
|
||||
stream_id: services()
|
||||
.users
|
||||
|
|
@ -1889,13 +1889,13 @@ pub(crate) async fn get_devices_route(
|
|||
/// Resolve a room alias to a room id.
|
||||
pub(crate) async fn get_room_information_route(
|
||||
body: Ruma<get_room_information::v1::Request>,
|
||||
) -> Result<RumaResponse<get_room_information::v1::Response>> {
|
||||
) -> Result<Ra<get_room_information::v1::Response>> {
|
||||
let room_id =
|
||||
services().rooms.alias.resolve_local_alias(&body.room_alias)?.ok_or(
|
||||
Error::BadRequest(ErrorKind::NotFound, "Room alias not found."),
|
||||
)?;
|
||||
|
||||
Ok(RumaResponse(get_room_information::v1::Response {
|
||||
Ok(Ra(get_room_information::v1::Response {
|
||||
room_id,
|
||||
servers: vec![services().globals.server_name().to_owned()],
|
||||
}))
|
||||
|
|
@ -1906,7 +1906,7 @@ pub(crate) async fn get_room_information_route(
|
|||
/// Gets information on a profile.
|
||||
pub(crate) async fn get_profile_information_route(
|
||||
body: Ruma<get_profile_information::v1::Request>,
|
||||
) -> Result<RumaResponse<get_profile_information::v1::Response>> {
|
||||
) -> Result<Ra<get_profile_information::v1::Response>> {
|
||||
if body.user_id.server_name() != services().globals.server_name() {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
|
|
@ -1935,7 +1935,7 @@ pub(crate) async fn get_profile_information_route(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(RumaResponse(get_profile_information::v1::Response {
|
||||
Ok(Ra(get_profile_information::v1::Response {
|
||||
displayname,
|
||||
avatar_url,
|
||||
blurhash,
|
||||
|
|
@ -1947,7 +1947,7 @@ pub(crate) async fn get_profile_information_route(
|
|||
/// Gets devices and identity keys for the given users.
|
||||
pub(crate) async fn get_keys_route(
|
||||
body: Ruma<get_keys::v1::Request>,
|
||||
) -> Result<RumaResponse<get_keys::v1::Response>> {
|
||||
) -> Result<Ra<get_keys::v1::Response>> {
|
||||
if body
|
||||
.device_keys
|
||||
.iter()
|
||||
|
|
@ -1964,7 +1964,7 @@ pub(crate) async fn get_keys_route(
|
|||
})
|
||||
.await?;
|
||||
|
||||
Ok(RumaResponse(get_keys::v1::Response {
|
||||
Ok(Ra(get_keys::v1::Response {
|
||||
device_keys: result.device_keys,
|
||||
master_keys: result.master_keys,
|
||||
self_signing_keys: result.self_signing_keys,
|
||||
|
|
@ -1976,7 +1976,7 @@ pub(crate) async fn get_keys_route(
|
|||
/// Claims one-time keys.
|
||||
pub(crate) async fn claim_keys_route(
|
||||
body: Ruma<claim_keys::v1::Request>,
|
||||
) -> Result<RumaResponse<claim_keys::v1::Response>> {
|
||||
) -> Result<Ra<claim_keys::v1::Response>> {
|
||||
if body
|
||||
.one_time_keys
|
||||
.iter()
|
||||
|
|
@ -1990,7 +1990,7 @@ pub(crate) async fn claim_keys_route(
|
|||
|
||||
let result = claim_keys_helper(&body.one_time_keys).await?;
|
||||
|
||||
Ok(RumaResponse(claim_keys::v1::Response {
|
||||
Ok(Ra(claim_keys::v1::Response {
|
||||
one_time_keys: result.one_time_keys,
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ mod database;
|
|||
mod service;
|
||||
mod utils;
|
||||
|
||||
pub(crate) use api::ruma_wrapper::{Ruma, RumaResponse};
|
||||
pub(crate) use api::ruma_wrapper::{Ra, Ruma};
|
||||
use api::{client_server, server_server};
|
||||
pub(crate) use config::Config;
|
||||
pub(crate) use database::KeyValueDatabase;
|
||||
|
|
@ -295,7 +295,7 @@ async fn unrecognized_method<B: Send>(
|
|||
let inner = next.run(req).await;
|
||||
if inner.status() == axum::http::StatusCode::METHOD_NOT_ALLOWED {
|
||||
warn!("Method not allowed: {method} {uri}");
|
||||
return Ok(RumaResponse(UiaaResponse::MatrixError(RumaError {
|
||||
return Ok(Ra(UiaaResponse::MatrixError(RumaError {
|
||||
body: ErrorBody::Standard {
|
||||
kind: ErrorKind::Unrecognized,
|
||||
message: "M_UNRECOGNIZED: Unrecognized request".to_owned(),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use ruma::{
|
|||
use thiserror::Error;
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::RumaResponse;
|
||||
use crate::Ra;
|
||||
|
||||
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ impl Error {
|
|||
Self::BadConfig(message)
|
||||
}
|
||||
|
||||
pub(crate) fn to_response(&self) -> RumaResponse<UiaaResponse> {
|
||||
pub(crate) fn to_response(&self) -> Ra<UiaaResponse> {
|
||||
use ErrorKind::{
|
||||
Forbidden, GuestAccessForbidden, LimitExceeded, MissingToken,
|
||||
NotFound, ThreepidAuthFailed, ThreepidDenied, TooLarge,
|
||||
|
|
@ -104,7 +104,7 @@ impl Error {
|
|||
};
|
||||
|
||||
if let Self::Uiaa(uiaainfo) = self {
|
||||
return RumaResponse(UiaaResponse::AuthResponse(uiaainfo.clone()));
|
||||
return Ra(UiaaResponse::AuthResponse(uiaainfo.clone()));
|
||||
}
|
||||
|
||||
if let Self::Federation(origin, error) = self {
|
||||
|
|
@ -113,7 +113,7 @@ impl Error {
|
|||
kind: Unknown,
|
||||
message: format!("Answer from {origin}: {error}"),
|
||||
};
|
||||
return RumaResponse(UiaaResponse::MatrixError(error));
|
||||
return Ra(UiaaResponse::MatrixError(error));
|
||||
}
|
||||
|
||||
let message = format!("{self}");
|
||||
|
|
@ -149,7 +149,7 @@ impl Error {
|
|||
|
||||
info!("Returning an error: {}: {}", status_code, message);
|
||||
|
||||
RumaResponse(UiaaResponse::MatrixError(RumaError {
|
||||
Ra(UiaaResponse::MatrixError(RumaError {
|
||||
body: ErrorBody::Standard {
|
||||
kind,
|
||||
message,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue