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.
22 lines
688 B
Rust
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(())
|
|
}
|