refactor: group use cases into DDD bounded contexts
Flat use_cases/ (44 files) + monolithic commands.rs/queries.rs split into diary/, movies/, watchlist/, import/, auth/, users/, integrations/, search/, person/, federation/ — each with own commands.rs, queries.rs, and use case modules. Inline tests extracted to sibling tests/ dirs.
This commit is contained in:
32
crates/application/src/users/get_current_profile.rs
Normal file
32
crates/application/src/users/get_current_profile.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use domain::errors::DomainError;
|
||||
|
||||
use crate::{context::AppContext, users::queries::GetCurrentProfileQuery};
|
||||
|
||||
pub struct CurrentProfileData {
|
||||
pub username: String,
|
||||
pub bio: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn execute(
|
||||
ctx: &AppContext,
|
||||
query: GetCurrentProfileQuery,
|
||||
) -> Result<CurrentProfileData, DomainError> {
|
||||
let user_id = domain::value_objects::UserId::from_uuid(query.user_id);
|
||||
let user = ctx
|
||||
.repos
|
||||
.user
|
||||
.find_by_id(&user_id)
|
||||
.await?
|
||||
.ok_or_else(|| DomainError::NotFound("User not found".into()))?;
|
||||
|
||||
let avatar_url = user
|
||||
.avatar_path()
|
||||
.map(|path| format!("{}/images/{}", ctx.config.base_url, path));
|
||||
|
||||
Ok(CurrentProfileData {
|
||||
username: user.username().value().to_string(),
|
||||
bio: user.bio().map(|s| s.to_string()),
|
||||
avatar_url,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user