From 706d7389ed9558a98868c6cbf232a39bb982960e Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 15 May 2026 03:14:09 +0200 Subject: [PATCH] refactor: replace inline find_by_id calls with get_user use case in presentation handlers --- crates/presentation/src/handlers/users.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/presentation/src/handlers/users.rs b/crates/presentation/src/handlers/users.rs index 1af4545..0def2d9 100644 --- a/crates/presentation/src/handlers/users.rs +++ b/crates/presentation/src/handlers/users.rs @@ -9,7 +9,9 @@ use api_types::{ responses::{ErrorResponse, ProfileField, RemoteActorResponse, UserResponse}, }; use application::use_cases::feed::list_users; -use application::use_cases::profile::{get_user_by_id_or_username, update_profile}; +use application::use_cases::profile::{ + get_user as fetch_user, get_user_by_id_or_username, update_profile, +}; use application::use_cases::search::search_users; use axum::{ extract::{Path, Query, State}, @@ -78,11 +80,7 @@ pub async fn patch_profile( body.custom_css, ) .await?; - let user = s - .users - .find_by_id(&uid) - .await? - .ok_or(domain::errors::DomainError::NotFound)?; + let user = fetch_user(&*s.users, &uid).await?; Ok(Json(to_user_response(&user))) } @@ -98,11 +96,7 @@ pub async fn get_me( State(s): State, AuthUser(uid): AuthUser, ) -> Result, ApiError> { - let user = s - .users - .find_by_id(&uid) - .await? - .ok_or(domain::errors::DomainError::NotFound)?; + let user = fetch_user(&*s.users, &uid).await?; Ok(Json(to_user_response(&user))) }