refactor: replace inline find_by_id calls with get_user use case in presentation handlers
This commit is contained in:
@@ -9,7 +9,9 @@ use api_types::{
|
|||||||
responses::{ErrorResponse, ProfileField, RemoteActorResponse, UserResponse},
|
responses::{ErrorResponse, ProfileField, RemoteActorResponse, UserResponse},
|
||||||
};
|
};
|
||||||
use application::use_cases::feed::list_users;
|
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 application::use_cases::search::search_users;
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, Query, State},
|
extract::{Path, Query, State},
|
||||||
@@ -78,11 +80,7 @@ pub async fn patch_profile(
|
|||||||
body.custom_css,
|
body.custom_css,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
let user = s
|
let user = fetch_user(&*s.users, &uid).await?;
|
||||||
.users
|
|
||||||
.find_by_id(&uid)
|
|
||||||
.await?
|
|
||||||
.ok_or(domain::errors::DomainError::NotFound)?;
|
|
||||||
Ok(Json(to_user_response(&user)))
|
Ok(Json(to_user_response(&user)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,11 +96,7 @@ pub async fn get_me(
|
|||||||
State(s): State<AppState>,
|
State(s): State<AppState>,
|
||||||
AuthUser(uid): AuthUser,
|
AuthUser(uid): AuthUser,
|
||||||
) -> Result<Json<UserResponse>, ApiError> {
|
) -> Result<Json<UserResponse>, ApiError> {
|
||||||
let user = s
|
let user = fetch_user(&*s.users, &uid).await?;
|
||||||
.users
|
|
||||||
.find_by_id(&uid)
|
|
||||||
.await?
|
|
||||||
.ok_or(domain::errors::DomainError::NotFound)?;
|
|
||||||
Ok(Json(to_user_response(&user)))
|
Ok(Json(to_user_response(&user)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user