diff --git a/src/api/client_server/account.rs b/src/api/client_server/account.rs index 39ec159a..180b90c2 100644 --- a/src/api/client_server/account.rs +++ b/src/api/client_server/account.rs @@ -19,7 +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, Ra, Result, Ruma}; +use crate::{api::client_server, services, utils, Ar, Error, Ra, Result}; const RANDOM_USER_ID_LENGTH: usize = 10; @@ -35,7 +35,7 @@ const RANDOM_USER_ID_LENGTH: usize = 10; /// Note: This will not reserve the username, so the username might become /// invalid when trying to register pub(crate) async fn get_register_available_route( - body: Ruma, + body: Ar, ) -> Result> { // Validate user id let user_id = UserId::parse_with_server_name( @@ -87,7 +87,7 @@ pub(crate) async fn get_register_available_route( /// `access_token` #[allow(clippy::too_many_lines)] pub(crate) async fn register_route( - body: Ruma, + body: Ar, ) -> Result> { if !services().globals.allow_registration() && body.appservice_info.is_none() @@ -327,7 +327,7 @@ pub(crate) async fn register_route( /// - Forgets to-device events /// - Triggers device list updates pub(crate) async fn change_password_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = @@ -390,7 +390,7 @@ pub(crate) async fn change_password_route( /// /// Note: Also works for Application Services pub(crate) async fn whoami_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let device_id = body.sender_device.as_ref().cloned(); @@ -415,7 +415,7 @@ pub(crate) async fn whoami_route( /// - Triggers device list updates /// - Removes ability to log in again pub(crate) async fn deactivate_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = @@ -472,7 +472,7 @@ pub(crate) async fn deactivate_route( /// /// - Currently always returns empty list pub(crate) async fn third_party_route( - body: Ruma, + body: Ar, ) -> Result> { let _sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -488,7 +488,7 @@ pub(crate) async fn third_party_route( /// - 403 signals that The homeserver does not allow the third party identifier /// as a contact option. pub(crate) async fn request_3pid_management_token_via_email_route( - _body: Ruma, + _body: Ar, ) -> Result> { Err(Error::BadRequest( ErrorKind::ThreepidDenied, @@ -504,7 +504,7 @@ 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. pub(crate) async fn request_3pid_management_token_via_msisdn_route( - _body: Ruma, + _body: Ar, ) -> Result> { Err(Error::BadRequest( ErrorKind::ThreepidDenied, diff --git a/src/api/client_server/alias.rs b/src/api/client_server/alias.rs index 39a1fe67..fb46dc55 100644 --- a/src/api/client_server/alias.rs +++ b/src/api/client_server/alias.rs @@ -11,13 +11,13 @@ use ruma::{ OwnedRoomAliasId, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `PUT /_matrix/client/r0/directory/room/{roomAlias}` /// /// Creates a new room alias on this server. pub(crate) async fn create_alias_route( - body: Ruma, + body: Ar, ) -> Result> { if body.room_alias.server_name() != services().globals.server_name() { return Err(Error::BadRequest( @@ -56,7 +56,7 @@ pub(crate) async fn create_alias_route( /// - TODO: additional access control checks /// - TODO: Update canonical alias event pub(crate) async fn delete_alias_route( - body: Ruma, + body: Ar, ) -> Result> { if body.room_alias.server_name() != services().globals.server_name() { return Err(Error::BadRequest( @@ -92,7 +92,7 @@ pub(crate) async fn delete_alias_route( /// /// - TODO: Suggest more servers to join via pub(crate) async fn get_alias_route( - body: Ruma, + body: Ar, ) -> Result> { get_alias_helper(body.body.room_alias).await.map(Ra) } diff --git a/src/api/client_server/backup.rs b/src/api/client_server/backup.rs index a33b766a..cc0a0640 100644 --- a/src/api/client_server/backup.rs +++ b/src/api/client_server/backup.rs @@ -9,13 +9,13 @@ use ruma::api::client::{ error::ErrorKind, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `POST /_matrix/client/r0/room_keys/version` /// /// Creates a new backup. pub(crate) async fn create_backup_version_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let version = @@ -31,7 +31,7 @@ pub(crate) async fn create_backup_version_route( /// Update information about an existing backup. Only `auth_data` can be /// modified. pub(crate) async fn update_backup_version_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); services().key_backups.update_backup( @@ -47,7 +47,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -75,7 +75,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let algorithm = services() @@ -105,7 +105,7 @@ pub(crate) async fn get_backup_info_route( /// - Deletes both information about the backup, as well as all key data related /// to the backup pub(crate) async fn delete_backup_version_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -123,7 +123,7 @@ pub(crate) async fn delete_backup_version_route( /// - Adds the keys to the backup /// - Returns the new number of keys in this backup and the etag pub(crate) async fn add_backup_keys_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -171,7 +171,7 @@ pub(crate) async fn add_backup_keys_route( /// - Adds the keys to the backup /// - Returns the new number of keys in this backup and the etag pub(crate) async fn add_backup_keys_for_room_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -217,7 +217,7 @@ pub(crate) async fn add_backup_keys_for_room_route( /// - Adds the keys to the backup /// - Returns the new number of keys in this backup and the etag pub(crate) async fn add_backup_keys_for_session_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -256,7 +256,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -271,7 +271,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -290,7 +290,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -316,7 +316,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -336,7 +336,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -360,7 +360,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/capabilities.rs b/src/api/client_server/capabilities.rs index 73c3a9c6..8a7d6b10 100644 --- a/src/api/client_server/capabilities.rs +++ b/src/api/client_server/capabilities.rs @@ -4,14 +4,14 @@ use ruma::api::client::discovery::get_capabilities::{ self, Capabilities, RoomVersionStability, RoomVersionsCapability, }; -use crate::{services, Ra, Result, Ruma}; +use crate::{services, Ar, Ra, Result}; /// # `GET /_matrix/client/r0/capabilities` /// /// Get information on the supported feature set and other relevent capabilities /// of this server. pub(crate) async fn get_capabilities_route( - _body: Ruma, + _body: Ar, ) -> Result> { let mut available = BTreeMap::new(); for room_version in &services().globals.unstable_room_versions { diff --git a/src/api/client_server/config.rs b/src/api/client_server/config.rs index dbff1e3b..8d9a0a84 100644 --- a/src/api/client_server/config.rs +++ b/src/api/client_server/config.rs @@ -14,13 +14,13 @@ use ruma::{ use serde::Deserialize; use serde_json::{json, value::RawValue as RawJsonValue}; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -48,7 +48,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -76,7 +76,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -101,7 +101,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/context.rs b/src/api/client_server/context.rs index 42cf8e62..e18706aa 100644 --- a/src/api/client_server/context.rs +++ b/src/api/client_server/context.rs @@ -9,7 +9,7 @@ use ruma::{ }; use tracing::error; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `GET /_matrix/client/r0/rooms/{roomId}/context` /// @@ -20,7 +20,7 @@ use crate::{services, Error, Ra, Result, Ruma}; /// joined, depending on `history_visibility`) #[allow(clippy::too_many_lines)] pub(crate) async fn get_context_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = diff --git a/src/api/client_server/device.rs b/src/api/client_server/device.rs index 92c67b41..ae243244 100644 --- a/src/api/client_server/device.rs +++ b/src/api/client_server/device.rs @@ -8,13 +8,13 @@ use ruma::api::client::{ }; use super::SESSION_ID_LENGTH; -use crate::{services, utils, Error, Ra, Result, Ruma}; +use crate::{services, utils, Ar, Error, Ra, Result}; /// # `GET /_matrix/client/r0/devices` /// /// Get metadata on all devices of the sender user. pub(crate) async fn get_devices_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -33,7 +33,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -51,7 +51,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -82,7 +82,7 @@ pub(crate) async fn update_device_route( /// - Forgets to-device events /// - Triggers device list updates pub(crate) async fn delete_device_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = @@ -136,7 +136,7 @@ pub(crate) async fn delete_device_route( /// - Forgets to-device events /// - Triggers device list updates pub(crate) async fn delete_devices_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = diff --git a/src/api/client_server/directory.rs b/src/api/client_server/directory.rs index 64727516..9aea4127 100644 --- a/src/api/client_server/directory.rs +++ b/src/api/client_server/directory.rs @@ -29,7 +29,7 @@ use ruma::{ }; use tracing::{error, info, warn}; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `POST /_matrix/client/r0/publicRooms` /// @@ -37,7 +37,7 @@ use crate::{services, Error, Ra, Result, Ruma}; /// /// - Rooms are ordered by the number of joined members pub(crate) async fn get_public_rooms_filtered_route( - body: Ruma, + body: Ar, ) -> Result> { get_public_rooms_filtered_helper( body.server.as_deref(), @@ -56,7 +56,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, + body: Ar, ) -> Result> { let response = get_public_rooms_filtered_helper( body.server.as_deref(), @@ -81,7 +81,7 @@ pub(crate) async fn get_public_rooms_route( /// /// - TODO: Access control checks pub(crate) async fn set_room_visibility_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -113,7 +113,7 @@ 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, + body: Ar, ) -> Result> { if !services().rooms.metadata.exists(&body.room_id)? { // Return 404 if the room doesn't exist diff --git a/src/api/client_server/filter.rs b/src/api/client_server/filter.rs index cfb2a4dc..e99f8b17 100644 --- a/src/api/client_server/filter.rs +++ b/src/api/client_server/filter.rs @@ -3,7 +3,7 @@ use ruma::api::client::{ filter::{create_filter, get_filter}, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}` /// @@ -11,7 +11,7 @@ use crate::{services, Error, Ra, Result, Ruma}; /// /// - A user can only access their own filters pub(crate) async fn get_filter_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let Some(filter) = @@ -30,7 +30,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); Ok(Ra(create_filter::v3::Response::new( diff --git a/src/api/client_server/keys.rs b/src/api/client_server/keys.rs index 3751f995..1c21e40b 100644 --- a/src/api/client_server/keys.rs +++ b/src/api/client_server/keys.rs @@ -23,7 +23,7 @@ use serde_json::json; use tracing::debug; use super::SESSION_ID_LENGTH; -use crate::{services, utils, Error, Ra, Result, Ruma}; +use crate::{services, utils, Ar, Error, Ra, Result}; /// # `POST /_matrix/client/r0/keys/upload` /// @@ -33,7 +33,7 @@ use crate::{services, utils, Error, Ra, Result, Ruma}; /// - If there are no device keys yet: Adds device keys (TODO: merge with /// existing keys?) pub(crate) async fn upload_keys_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = @@ -80,7 +80,7 @@ pub(crate) async fn upload_keys_route( /// - The master and self-signing keys contain signatures that the user is /// allowed to see pub(crate) async fn get_keys_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -96,7 +96,7 @@ pub(crate) async fn get_keys_route( /// /// Claims one-time keys pub(crate) async fn claim_keys_route( - body: Ruma, + body: Ar, ) -> Result> { let response = claim_keys_helper(&body.one_time_keys).await?; @@ -109,7 +109,7 @@ pub(crate) async fn claim_keys_route( /// /// - Requires UIAA to verify password pub(crate) async fn upload_signing_keys_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = @@ -163,7 +163,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -226,7 +226,7 @@ pub(crate) async fn upload_signatures_route( /// /// - TODO: left users pub(crate) async fn get_key_changes_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/media.rs b/src/api/client_server/media.rs index 8b3aa85b..cbea2009 100644 --- a/src/api/client_server/media.rs +++ b/src/api/client_server/media.rs @@ -8,9 +8,7 @@ use ruma::api::client::{ }, }; -use crate::{ - service::media::FileMeta, services, utils, Error, Ra, Result, Ruma, -}; +use crate::{service::media::FileMeta, services, utils, Ar, Error, Ra, Result}; const MXC_LENGTH: usize = 32; @@ -18,7 +16,7 @@ const MXC_LENGTH: usize = 32; /// /// Returns max upload size. pub(crate) async fn get_media_config_route( - _body: Ruma, + _body: Ar, ) -> Result> { Ok(Ra(get_media_config::v3::Response { upload_size: services().globals.max_request_size().into(), @@ -32,7 +30,7 @@ pub(crate) async fn get_media_config_route( /// - Some metadata will be saved in the database /// - Media will be saved in the media/ directory pub(crate) async fn create_content_route( - body: Ruma, + body: Ar, ) -> Result> { let mxc = format!( "mxc://{}/{}", @@ -97,7 +95,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, + body: Ar, ) -> Result> { let mxc = format!("mxc://{}/{}", body.server_name, body.media_id); @@ -131,7 +129,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, + body: Ar, ) -> Result> { let mxc = format!("mxc://{}/{}", body.server_name, body.media_id); @@ -177,7 +175,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, + body: Ar, ) -> Result> { let mxc = format!("mxc://{}/{}", body.server_name, body.media_id); diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index 229b45b0..1586a4dd 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -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, Ra, Result, Ruma, + services, utils, Ar, Error, PduEvent, Ra, Result, }; /// # `POST /_matrix/client/r0/rooms/{roomId}/join` @@ -48,7 +48,7 @@ use crate::{ /// - If the server does not know about the room: asks other servers over /// federation pub(crate) async fn join_room_by_id_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -95,7 +95,7 @@ pub(crate) async fn join_room_by_id_route( /// - If the server does not know about the room: asks other servers over /// federation pub(crate) async fn join_room_by_id_or_alias_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_deref().expect("user is authenticated"); @@ -159,7 +159,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -172,7 +172,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -198,7 +198,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -267,7 +267,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -351,7 +351,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -428,7 +428,7 @@ pub(crate) async fn unban_user_route( /// Note: Other devices of the user have no way of knowing the room was /// forgotten, so this has to be called from every device pub(crate) async fn forget_room_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -441,7 +441,7 @@ pub(crate) async fn forget_room_route( /// /// Lists all rooms the user has joined. pub(crate) async fn joined_rooms_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -462,7 +462,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -497,7 +497,7 @@ pub(crate) async fn get_member_events_route( /// - The sender user must be in the room /// - TODO: An appservice just needs a puppet joined pub(crate) async fn joined_members_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/message.rs b/src/api/client_server/message.rs index 6a16f6f6..6fe47f18 100644 --- a/src/api/client_server/message.rs +++ b/src/api/client_server/message.rs @@ -14,7 +14,7 @@ use ruma::{ use crate::{ service::{pdu::PduBuilder, rooms::timeline::PduCount}, - services, utils, Error, Ra, Result, Ruma, + services, utils, Ar, Error, Ra, Result, }; /// # `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}` @@ -27,7 +27,7 @@ use crate::{ /// - Tries to send the event into the room, auth rules will determine if it is /// allowed pub(crate) async fn send_message_event_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = body.sender_device.as_deref(); @@ -130,7 +130,7 @@ pub(crate) async fn send_message_event_route( /// joined, depending on `history_visibility`) #[allow(clippy::too_many_lines)] pub(crate) async fn get_message_events_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = diff --git a/src/api/client_server/profile.rs b/src/api/client_server/profile.rs index 1a51815d..8557baab 100644 --- a/src/api/client_server/profile.rs +++ b/src/api/client_server/profile.rs @@ -18,7 +18,7 @@ use ruma::{ use serde_json::value::to_raw_value; use tracing::warn; -use crate::{service::pdu::PduBuilder, services, Error, Ra, Result, Ruma}; +use crate::{service::pdu::PduBuilder, services, Ar, Error, Ra, Result}; /// # `PUT /_matrix/client/r0/profile/{userId}/displayname` /// @@ -26,7 +26,7 @@ use crate::{service::pdu::PduBuilder, services, Error, Ra, Result, Ruma}; /// /// - Also makes sure other users receive the update using presence EDUs pub(crate) async fn set_displayname_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -116,7 +116,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, + body: Ar, ) -> Result> { if body.user_id.server_name() != services().globals.server_name() { let response = services() @@ -146,7 +146,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -239,7 +239,7 @@ pub(crate) async fn set_avatar_url_route( /// - If user is on another server: Fetches `avatar_url` and `blurhash` over /// federation pub(crate) async fn get_avatar_url_route( - body: Ruma, + body: Ar, ) -> Result> { if body.user_id.server_name() != services().globals.server_name() { let response = services() @@ -271,7 +271,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, + body: Ar, ) -> Result> { if body.user_id.server_name() != services().globals.server_name() { let response = services() diff --git a/src/api/client_server/push.rs b/src/api/client_server/push.rs index ae41a6d5..39a2cd13 100644 --- a/src/api/client_server/push.rs +++ b/src/api/client_server/push.rs @@ -11,13 +11,13 @@ use ruma::{ push::{AnyPushRuleRef, InsertPushRuleError, RemovePushRuleError}, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `GET /_matrix/client/r0/pushrules` /// /// Retrieves the push rules event for this user. pub(crate) async fn get_pushrules_all_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -46,7 +46,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -84,7 +84,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let body = body.body; @@ -164,7 +164,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -209,7 +209,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -264,7 +264,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -310,7 +310,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -365,7 +365,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -425,7 +425,7 @@ 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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -440,7 +440,7 @@ pub(crate) async fn get_pushers_route( /// /// - TODO: Handle `append` pub(crate) async fn set_pushers_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/read_marker.rs b/src/api/client_server/read_marker.rs index 52eed945..c30a4cb8 100644 --- a/src/api/client_server/read_marker.rs +++ b/src/api/client_server/read_marker.rs @@ -12,7 +12,7 @@ use ruma::{ }; use crate::{ - service::rooms::timeline::PduCount, services, Error, Ra, Result, Ruma, + service::rooms::timeline::PduCount, services, Ar, Error, Ra, Result, }; /// # `POST /_matrix/client/r0/rooms/{roomId}/read_markers` @@ -23,7 +23,7 @@ use crate::{ /// - If `read_receipt` is set: Update private marker and public read receipt /// EDU pub(crate) async fn set_read_marker_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -104,7 +104,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/redact.rs b/src/api/client_server/redact.rs index 5f5395d8..5604bfb0 100644 --- a/src/api/client_server/redact.rs +++ b/src/api/client_server/redact.rs @@ -6,7 +6,7 @@ use ruma::{ }; use serde_json::value::to_raw_value; -use crate::{service::pdu::PduBuilder, services, Ra, Result, Ruma}; +use crate::{service::pdu::PduBuilder, services, Ar, Ra, Result}; /// # `PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}` /// @@ -14,7 +14,7 @@ use crate::{service::pdu::PduBuilder, services, Ra, Result, Ruma}; /// /// - TODO: Handle txn id pub(crate) async fn redact_event_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let body = body.body; diff --git a/src/api/client_server/relations.rs b/src/api/client_server/relations.rs index 7124bc7b..1713fb57 100644 --- a/src/api/client_server/relations.rs +++ b/src/api/client_server/relations.rs @@ -6,11 +6,11 @@ use ruma::{ uint, }; -use crate::{service::rooms::timeline::PduCount, services, Ra, Result, Ruma}; +use crate::{service::rooms::timeline::PduCount, services, Ar, Ra, Result}; /// # `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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -54,7 +54,7 @@ pub(crate) async fn get_relating_events_with_rel_type_and_event_type_route( /// # `GET /_matrix/client/r0/rooms/{roomId}/relations/{eventId}/{relType}` pub(crate) async fn get_relating_events_with_rel_type_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -97,7 +97,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/report.rs b/src/api/client_server/report.rs index f1102fb5..edf18057 100644 --- a/src/api/client_server/report.rs +++ b/src/api/client_server/report.rs @@ -4,13 +4,13 @@ use ruma::{ int, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}` /// /// Reports an inappropriate event to homeserver admins pub(crate) async fn report_event_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs index 15e5613d..87111aa9 100644 --- a/src/api/client_server/room.rs +++ b/src/api/client_server/room.rs @@ -30,8 +30,8 @@ use serde_json::{json, value::to_raw_value}; use tracing::{info, warn}; use crate::{ - api::client_server::invite_helper, service::pdu::PduBuilder, services, - Error, Ra, Result, Ruma, + api::client_server::invite_helper, service::pdu::PduBuilder, services, Ar, + Error, Ra, Result, }; /// # `POST /_matrix/client/r0/createRoom` @@ -52,7 +52,7 @@ use crate::{ /// - Send invite events #[allow(clippy::too_many_lines)] pub(crate) async fn create_room_route( - body: Ruma, + body: Ar, ) -> Result> { use create_room::v3::RoomPreset; @@ -548,7 +548,7 @@ pub(crate) async fn create_room_route( /// - You have to currently be joined to the room (TODO: Respect history /// visibility) pub(crate) async fn get_room_event_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -585,7 +585,7 @@ pub(crate) async fn get_room_event_route( /// - Only users joined to the room are allowed to call this TODO: Allow any /// user to call it if `history_visibility` is world readable pub(crate) async fn get_room_aliases_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -618,7 +618,7 @@ pub(crate) async fn get_room_aliases_route( /// - Modifies old room power levels to prevent users from speaking #[allow(clippy::too_many_lines)] pub(crate) async fn upgrade_room_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/search.rs b/src/api/client_server/search.rs index 628a8b2c..111281a2 100644 --- a/src/api/client_server/search.rs +++ b/src/api/client_server/search.rs @@ -14,7 +14,7 @@ use ruma::{ uint, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `POST /_matrix/client/r0/search` /// @@ -24,7 +24,7 @@ use crate::{services, Error, Ra, Result, Ruma}; /// history visibility) #[allow(clippy::too_many_lines)] pub(crate) async fn search_events_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/session.rs b/src/api/client_server/session.rs index ed3b165a..6d740acc 100644 --- a/src/api/client_server/session.rs +++ b/src/api/client_server/session.rs @@ -16,7 +16,7 @@ use serde::Deserialize; use tracing::{info, warn}; use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH}; -use crate::{services, utils, Error, Ra, Result, Ruma}; +use crate::{services, utils, Ar, Error, Ra, Result}; #[derive(Debug, Deserialize)] struct Claims { @@ -28,7 +28,7 @@ struct Claims { /// Get the supported login types of this server. One of these should be used as /// the `type` field when logging in. pub(crate) async fn get_login_types_route( - _body: Ruma, + _body: Ar, ) -> Result> { Ok(Ra(get_login_types::v3::Response::new(vec![ get_login_types::v3::LoginType::Password(PasswordLoginType::default()), @@ -53,7 +53,7 @@ pub(crate) async fn get_login_types_route( /// see supported login types. #[allow(clippy::too_many_lines)] pub(crate) async fn login_route( - body: Ruma, + body: Ar, ) -> Result> { // To allow deprecated login methods #![allow(deprecated)] @@ -277,7 +277,7 @@ pub(crate) async fn login_route( /// - Forgets to-device events /// - Triggers device list updates pub(crate) async fn logout_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = @@ -310,7 +310,7 @@ pub(crate) async fn logout_route( /// Note: This is equivalent to calling [`GET /// /_matrix/client/r0/logout`](logout_route) from each device of this user. pub(crate) async fn logout_all_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/space.rs b/src/api/client_server/space.rs index 44c0939e..930814e8 100644 --- a/src/api/client_server/space.rs +++ b/src/api/client_server/space.rs @@ -1,13 +1,13 @@ use ruma::{api::client::space::get_hierarchy, uint}; -use crate::{services, Ra, Result, Ruma}; +use crate::{services, Ar, Ra, Result}; /// # `GET /_matrix/client/v1/rooms/{room_id}/hierarchy` /// /// Paginates over the space tree in a depth-first manner to locate child rooms /// of a given space. pub(crate) async fn get_hierarchy_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/state.rs b/src/api/client_server/state.rs index 5cbf0b9c..f04ae3fd 100644 --- a/src/api/client_server/state.rs +++ b/src/api/client_server/state.rs @@ -14,7 +14,7 @@ use ruma::{ }; use tracing::log::warn; -use crate::{service::pdu::PduBuilder, services, Error, Ra, Result, Ruma}; +use crate::{service::pdu::PduBuilder, services, Ar, Error, Ra, Result}; /// # `PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}` /// @@ -25,7 +25,7 @@ use crate::{service::pdu::PduBuilder, services, Error, Ra, Result, Ruma}; /// allowed /// - If event is new `canonical_alias`: Rejects if alias is incorrect pub(crate) async fn send_state_event_for_key_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -54,7 +54,7 @@ pub(crate) async fn send_state_event_for_key_route( /// allowed /// - If event is new `canonical_alias`: Rejects if alias is incorrect pub(crate) async fn send_state_event_for_empty_key_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -91,7 +91,7 @@ pub(crate) async fn send_state_event_for_empty_key_route( /// - If not joined: Only works if current room history visibility is world /// readable pub(crate) async fn get_state_events_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -125,7 +125,7 @@ pub(crate) async fn get_state_events_route( /// - If not joined: Only works if current room history visibility is world /// readable pub(crate) async fn get_state_events_for_key_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -166,7 +166,7 @@ pub(crate) async fn get_state_events_for_key_route( /// - If not joined: Only works if current room history visibility is world /// readable pub(crate) async fn get_state_events_for_empty_key_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/sync.rs b/src/api/client_server/sync.rs index a1e78f52..cbca2b49 100644 --- a/src/api/client_server/sync.rs +++ b/src/api/client_server/sync.rs @@ -29,7 +29,7 @@ use tracing::{debug, error}; use crate::{ service::{pdu::EventHash, rooms::timeline::PduCount}, - services, utils, Error, PduEvent, Ra, Result, Ruma, + services, utils, Ar, Error, PduEvent, Ra, Result, }; /// # `GET /_matrix/client/r0/sync` @@ -73,7 +73,7 @@ use crate::{ /// subset of the state at the point of the leave) #[allow(clippy::too_many_lines)] pub(crate) async fn sync_events_route( - body: Ruma, + body: Ar, ) -> Result, Ra> { let sender_user = body.sender_user.expect("user is authenticated"); let sender_device = body.sender_device.expect("user is authenticated"); @@ -1126,7 +1126,7 @@ fn share_encrypted_room( #[allow(clippy::too_many_lines)] pub(crate) async fn sync_events_v4_route( - body: Ruma, + body: Ar, ) -> Result, Ra> { let sender_user = body.sender_user.expect("user is authenticated"); let sender_device = body.sender_device.expect("user is authenticated"); diff --git a/src/api/client_server/tag.rs b/src/api/client_server/tag.rs index 94a2954a..17367300 100644 --- a/src/api/client_server/tag.rs +++ b/src/api/client_server/tag.rs @@ -8,7 +8,7 @@ use ruma::{ }, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}` /// @@ -16,7 +16,7 @@ use crate::{services, Error, Ra, Result, Ruma}; /// /// - Inserts the tag into the tag event of the room account data. pub(crate) async fn update_tag_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -62,7 +62,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); @@ -105,7 +105,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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/thirdparty.rs b/src/api/client_server/thirdparty.rs index 29f2da38..a22fa548 100644 --- a/src/api/client_server/thirdparty.rs +++ b/src/api/client_server/thirdparty.rs @@ -2,13 +2,13 @@ use std::collections::BTreeMap; use ruma::api::client::thirdparty::get_protocols; -use crate::{Ra, Result, Ruma}; +use crate::{Ar, Ra, Result}; /// # `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, + _body: Ar, ) -> Result> { // TODO Ok(Ra(get_protocols::v3::Response { diff --git a/src/api/client_server/threads.rs b/src/api/client_server/threads.rs index 518a736a..cf96e234 100644 --- a/src/api/client_server/threads.rs +++ b/src/api/client_server/threads.rs @@ -1,10 +1,10 @@ use ruma::api::client::{error::ErrorKind, threads::get_threads}; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `GET /_matrix/client/r0/rooms/{roomId}/threads` pub(crate) async fn get_threads_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/client_server/to_device.rs b/src/api/client_server/to_device.rs index 17427f84..65fb198c 100644 --- a/src/api/client_server/to_device.rs +++ b/src/api/client_server/to_device.rs @@ -8,13 +8,13 @@ use ruma::{ to_device::DeviceIdOrAllDevices, }; -use crate::{services, Error, Ra, Result, Ruma}; +use crate::{services, Ar, Error, Ra, Result}; /// # `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, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_device = body.sender_device.as_deref(); diff --git a/src/api/client_server/typing.rs b/src/api/client_server/typing.rs index d2226ee1..f6cf9bc0 100644 --- a/src/api/client_server/typing.rs +++ b/src/api/client_server/typing.rs @@ -1,12 +1,12 @@ use ruma::api::client::{error::ErrorKind, typing::create_typing_event}; -use crate::{services, utils, Error, Ra, Result, Ruma}; +use crate::{services, utils, Ar, Error, Ra, Result}; /// # `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, + body: Ar, ) -> Result> { use create_typing_event::v3::Typing; diff --git a/src/api/client_server/unversioned.rs b/src/api/client_server/unversioned.rs index bdd8e048..8ea8136c 100644 --- a/src/api/client_server/unversioned.rs +++ b/src/api/client_server/unversioned.rs @@ -2,7 +2,7 @@ use std::{collections::BTreeMap, iter::FromIterator}; use ruma::api::client::discovery::get_supported_versions; -use crate::{Ra, Result, Ruma}; +use crate::{Ar, Ra, Result}; /// # `GET /_matrix/client/versions` /// @@ -17,7 +17,7 @@ use crate::{Ra, Result, Ruma}; /// Note: Unstable features are used while developing new features. Clients /// should avoid using unstable features in their stable releases pub(crate) async fn get_supported_versions_route( - _body: Ruma, + _body: Ar, ) -> Result> { let resp = get_supported_versions::Response { versions: vec![ diff --git a/src/api/client_server/user_directory.rs b/src/api/client_server/user_directory.rs index 06970f4b..93fbd6cd 100644 --- a/src/api/client_server/user_directory.rs +++ b/src/api/client_server/user_directory.rs @@ -6,7 +6,7 @@ use ruma::{ }, }; -use crate::{services, Ra, Result, Ruma}; +use crate::{services, Ar, Ra, Result}; /// # `POST /_matrix/client/r0/user_directory/search` /// @@ -16,7 +16,7 @@ use crate::{services, Ra, Result, Ruma}; /// have the join rule set to public) /// and don't share a room with the sender pub(crate) async fn search_users_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let limit = body.limit.try_into().unwrap_or(usize::MAX); diff --git a/src/api/client_server/voip.rs b/src/api/client_server/voip.rs index 91507004..f24ca81e 100644 --- a/src/api/client_server/voip.rs +++ b/src/api/client_server/voip.rs @@ -5,7 +5,7 @@ use hmac::{Hmac, Mac}; use ruma::{api::client::voip::get_turn_server_info, SecondsSinceUnixEpoch}; use sha1::Sha1; -use crate::{services, Ra, Result, Ruma}; +use crate::{services, Ar, Ra, Result}; type HmacSha1 = Hmac; @@ -13,7 +13,7 @@ type HmacSha1 = Hmac; /// /// TODO: Returns information about the recommended turn server. pub(crate) async fn turn_server_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); diff --git a/src/api/ruma_wrapper.rs b/src/api/ruma_wrapper.rs index e0ab3368..f64e29f8 100644 --- a/src/api/ruma_wrapper.rs +++ b/src/api/ruma_wrapper.rs @@ -9,8 +9,12 @@ use crate::{service::appservice::RegistrationInfo, Error}; mod axum; -/// Extractor for Ruma request structs -pub(crate) struct Ruma { +/// A wrapper to convert an Axum request to Ruma data +/// +/// Named so because this converts from **A**xum to **R**uma. See also [`Ra`], +/// which is roughly the inverse of this type. +pub(crate) struct Ar { + /// The Ruma type to deserialize the body into pub(crate) body: T, pub(crate) sender_user: Option, pub(crate) sender_device: Option, @@ -20,7 +24,7 @@ pub(crate) struct Ruma { pub(crate) appservice_info: Option, } -impl Deref for Ruma { +impl Deref for Ar { type Target = T; fn deref(&self) -> &Self::Target { @@ -30,7 +34,7 @@ impl Deref for Ruma { /// A wrapper to convert Ruma data to an Axum response /// -/// Named so because this converts from **R**uma to **A**xum. See also [`Ruma`], +/// Named so because this converts from **R**uma to **A**xum. See also [`Ar`], /// which is roughly the inverse of this type. #[derive(Clone)] pub(crate) struct Ra(pub(crate) T); diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index ef3460c2..f55ffd85 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -24,7 +24,7 @@ use ruma::{ use serde::Deserialize; use tracing::{debug, error, warn}; -use super::{Ra, Ruma}; +use super::{Ar, Ra}; use crate::{service::appservice::RegistrationInfo, services, Error, Result}; enum Token { @@ -35,7 +35,7 @@ enum Token { } #[async_trait] -impl FromRequest for Ruma +impl FromRequest for Ar where T: IncomingRequest, B: HttpBody + Send + 'static, @@ -379,7 +379,7 @@ where ) })?; - Ok(Ruma { + Ok(Ar { body, sender_user, sender_device, diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 23bb3461..4529e02d 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -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, Ra, Result, Ruma, + services, utils, Ar, Error, PduEvent, Ra, Result, }; /// Wraps either an literal IP address plus port, or a hostname plus complement @@ -553,7 +553,7 @@ async fn request_well_known(destination: &str) -> Option { /// /// Get version information on this server. pub(crate) async fn get_server_version_route( - _body: Ruma, + _body: Ar, ) -> Result> { Ok(Ra(get_server_version::v1::Response { server: Some(get_server_version::v1::Server { @@ -630,7 +630,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, + body: Ar, ) -> Result> { let response = client_server::get_public_rooms_filtered_helper( None, @@ -653,7 +653,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, + body: Ar, ) -> Result> { let response = client_server::get_public_rooms_filtered_helper( None, @@ -708,7 +708,7 @@ pub(crate) fn parse_incoming_pdu( /// Push EDUs and PDUs to this server. #[allow(clippy::too_many_lines)] pub(crate) async fn send_transaction_message_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -991,7 +991,7 @@ pub(crate) async fn send_transaction_message_route( /// - Only works if a user of this server is currently invited or joined the /// room pub(crate) async fn get_event_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1047,7 +1047,7 @@ pub(crate) async fn get_event_route( /// Retrieves events from before the sender joined the room, if the room's /// history visibility allows. pub(crate) async fn get_backfill_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1117,7 +1117,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, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1219,7 +1219,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, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1277,7 +1277,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, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1347,7 +1347,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, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1402,7 +1402,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, + body: Ar, ) -> Result> { if !services().rooms.metadata.exists(&body.room_id)? { return Err(Error::BadRequest( @@ -1660,7 +1660,7 @@ async fn create_join_event( /// /// Submits a signed join event. pub(crate) async fn create_join_event_v1_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1677,7 +1677,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, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1705,7 +1705,7 @@ pub(crate) async fn create_join_event_v2_route( /// Invites a remote user to a room. #[allow(clippy::too_many_lines)] pub(crate) async fn create_invite_route( - body: Ruma, + body: Ar, ) -> Result> { let sender_servername = body.sender_servername.as_ref().expect("server is authenticated"); @@ -1836,7 +1836,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, + body: Ar, ) -> Result> { if body.user_id.server_name() != services().globals.server_name() { return Err(Error::BadRequest( @@ -1888,7 +1888,7 @@ 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, + body: Ar, ) -> Result> { let room_id = services().rooms.alias.resolve_local_alias(&body.room_alias)?.ok_or( @@ -1905,7 +1905,7 @@ pub(crate) async fn get_room_information_route( /// /// Gets information on a profile. pub(crate) async fn get_profile_information_route( - body: Ruma, + body: Ar, ) -> Result> { if body.user_id.server_name() != services().globals.server_name() { return Err(Error::BadRequest( @@ -1946,7 +1946,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, + body: Ar, ) -> Result> { if body .device_keys @@ -1975,7 +1975,7 @@ pub(crate) async fn get_keys_route( /// /// Claims one-time keys. pub(crate) async fn claim_keys_route( - body: Ruma, + body: Ar, ) -> Result> { if body .one_time_keys diff --git a/src/main.rs b/src/main.rs index c1a7d9e3..ddfc8e18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,7 @@ mod database; mod service; mod utils; -pub(crate) use api::ruma_wrapper::{Ra, Ruma}; +pub(crate) use api::ruma_wrapper::{Ar, Ra}; use api::{client_server, server_server}; pub(crate) use config::Config; pub(crate) use database::KeyValueDatabase; @@ -580,11 +580,11 @@ macro_rules! impl_ruma_handler { #[axum::async_trait] #[allow(non_snake_case)] impl - RumaHandler<($($ty,)* Ruma,)> for F + RumaHandler<($($ty,)* Ar,)> for F where Req: IncomingRequest + Send + 'static, Resp: IntoResponse, - F: FnOnce($($ty,)* Ruma) -> Fut + Clone + Send + 'static, + F: FnOnce($($ty,)* Ar) -> Fut + Clone + Send + 'static, Fut: Future> + Send, E: IntoResponse,