diff --git a/src/api/client/account/mod.rs b/src/api/client/account/mod.rs index e666cae27..db3de3b38 100644 --- a/src/api/client/account/mod.rs +++ b/src/api/client/account/mod.rs @@ -109,10 +109,7 @@ pub(crate) async fn change_password_route( ClientIp(client): ClientIp, body: Ruma, ) -> Result { - let identity = if let Some(user_id) = body - .identity - .as_ref() - .map(|identity| identity.sender_user()) + let identity = if let Some(user_id) = body.identity.as_ref().map(ClientIdentity::sender_user) { // A signed-in user is trying to change their password, prompt them for their // existing one @@ -282,7 +279,7 @@ pub(crate) async fn deactivate_route( let sender_user = body .identity .as_ref() - .map(|identity| identity.sender_user()) + .map(ClientIdentity::sender_user) .ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?; // Prompt the user to confirm with their password using UIAA diff --git a/src/api/client/account/threepid.rs b/src/api/client/account/threepid.rs index 2da54b0be..fe9d700f5 100644 --- a/src/api/client/account/threepid.rs +++ b/src/api/client/account/threepid.rs @@ -13,7 +13,7 @@ use ruma::{ }; use service::{mailer::messages, uiaa::Identity}; -use crate::Ruma; +use crate::{Ruma, router::ClientIdentity}; /// # `GET _matrix/client/v3/account/3pid` /// @@ -58,7 +58,7 @@ pub(crate) async fn request_3pid_management_token_via_email_route( let sender_user = body .identity .as_ref() - .map(|identity| identity.sender_user()) + .map(ClientIdentity::sender_user) .ok_or_else(|| err!(Request(MissingToken("Missing access token."))))?; if !services.threepid.email_requirement().may_change() { diff --git a/src/api/client/room/summary.rs b/src/api/client/room/summary.rs index 32e60617a..581b1de7d 100644 --- a/src/api/client/room/summary.rs +++ b/src/api/client/room/summary.rs @@ -4,7 +4,7 @@ use conduwuit::{Err, Result}; use ruma::api::client::room::get_summary; use service::rooms::summary::Accessibility; -use crate::Ruma; +use crate::{Ruma, router::ClientIdentity}; /// # `GET /_matrix/client/v1/room_summary/{roomIdOrAlias}` /// @@ -29,9 +29,7 @@ pub(crate) async fn get_room_summary( .rooms .summary .get_room_summary_for_user( - body.identity - .as_ref() - .map(|identity| identity.sender_user()), + body.identity.as_ref().map(ClientIdentity::sender_user), &room_id, &servers, ) diff --git a/src/api/client/sync/v5.rs b/src/api/client/sync/v5.rs index a6c340c53..900619c5f 100644 --- a/src/api/client/sync/v5.rs +++ b/src/api/client/sync/v5.rs @@ -93,7 +93,7 @@ pub(crate) async fn sync_events_v5_route( .and_then(|string| string.parse().ok()) .unwrap_or(0); - let snake_key = into_snake_key(sender_user.as_ref(), sender_device.as_str(), conn_id); + let snake_key = into_snake_key(sender_user, sender_device.as_str(), conn_id); if globalsince != 0 && !services.sync.snake_connection_cached(&snake_key) { return Err!(Request(UnknownPos( diff --git a/src/api/router/auth.rs b/src/api/router/auth.rs index b2a9b9ab0..3cbeb6ccb 100644 --- a/src/api/router/auth.rs +++ b/src/api/router/auth.rs @@ -28,7 +28,7 @@ pub(crate) enum ClientIdentity { Appservice { sender_user: OwnedUserId, sender_device: Option, - appservice_info: RegistrationInfo, + appservice_info: Box, }, } @@ -49,7 +49,7 @@ impl ClientIdentity { pub(crate) fn expect_sender_device(&self) -> Result<&DeviceId> { self.sender_device().ok_or_else(|| { - err!(Request(Forbidden("Appservices must masquerade to use this endpoint"))) + err!(Request(Forbidden("Appservices must masquerade to use this endpoint."))) }) } @@ -212,10 +212,10 @@ impl CheckAuth for AccessToken { Ok(ClientIdentity::Appservice { sender_user, sender_device, - appservice_info, + appservice_info: Box::new(appservice_info), }) } else { - return Err!(Request(Unauthorized("Invalid access token."))); + Err!(Request(Unauthorized("Invalid access token."))) } } } diff --git a/src/api/server/send.rs b/src/api/server/send.rs index 3f0531287..81fb24cf2 100644 --- a/src/api/server/send.rs +++ b/src/api/server/send.rs @@ -80,7 +80,7 @@ pub(crate) async fn send_transaction_message_route( ))); } - let txn_key = (body.identity.to_owned(), body.transaction_id.clone()); + let txn_key = (body.identity.clone(), body.transaction_id.clone()); // Atomically check cache, join active, or start new transaction match services