From 7710f19125e91451fcfe93eee55a5fd4eaebfe5e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 24 Jan 2024 13:42:22 +0100 Subject: [PATCH] refactor: [#39] userId extractor - upload handler --- src/web/api/v1/contexts/torrent/handlers.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/web/api/v1/contexts/torrent/handlers.rs b/src/web/api/v1/contexts/torrent/handlers.rs index bab51443..4e50f2b8 100644 --- a/src/web/api/v1/contexts/torrent/handlers.rs +++ b/src/web/api/v1/contexts/torrent/handlers.rs @@ -23,6 +23,7 @@ use crate::services::torrent_file::generate_random_torrent; use crate::utils::parse_torrent; use crate::web::api::v1::auth::get_optional_logged_in_user; use crate::web::api::v1::extractors::bearer_token::Extract; +use crate::web::api::v1::extractors::user_id::ExtractLoggedInUser; use crate::web::api::v1::responses::OkResponseData; use crate::web::api::v1::routes::API_VERSION_URL_PREFIX; @@ -37,14 +38,9 @@ use crate::web::api::v1::routes::API_VERSION_URL_PREFIX; #[allow(clippy::unused_async)] pub async fn upload_torrent_handler( State(app_data): State>, - Extract(maybe_bearer_token): Extract, + ExtractLoggedInUser(user_id): ExtractLoggedInUser, multipart: Multipart, ) -> Response { - let user_id = match app_data.auth.get_user_id_from_bearer_token(&maybe_bearer_token).await { - Ok(user_id) => user_id, - Err(error) => return error.into_response(), - }; - let add_torrent_form = match build_add_torrent_request_from_payload(multipart).await { Ok(torrent_request) => torrent_request, Err(error) => return error.into_response(),