refactor: replace inline find_by_id calls with get_user use case in presentation handlers

This commit is contained in:
2026-05-15 03:14:09 +02:00
parent 6e9b1596d8
commit 706d7389ed

View File

@@ -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<AppState>,
AuthUser(uid): AuthUser,
) -> Result<Json<UserResponse>, 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)))
}