Files
movies-diary/crates/application/src/users/update_profile_fields.rs
Gabriel Kaszewski dcc9244d4e 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.
2026-06-02 19:49:09 +02:00

22 lines
688 B
Rust

use domain::{errors::DomainError, events::DomainEvent, value_objects::UserId};
use crate::{context::AppContext, users::commands::UpdateProfileFieldsCommand};
pub async fn execute(ctx: &AppContext, cmd: UpdateProfileFieldsCommand) -> Result<(), DomainError> {
if cmd.fields.len() > 4 {
return Err(DomainError::ValidationError(
"Maximum 4 profile fields allowed".into(),
));
}
let user_id = UserId::from_uuid(cmd.user_id);
ctx.repos
.profile_fields
.set_fields(&user_id, cmd.fields)
.await?;
ctx.services
.event_publisher
.publish(&DomainEvent::UserUpdated { user_id })
.await?;
Ok(())
}