feat: atomic goal, watchlist, profile writes
This commit is contained in:
@@ -58,7 +58,6 @@ pub struct GetCurrentProfileDeps {
|
||||
|
||||
pub struct UpdateProfileFieldsDeps {
|
||||
pub profile_fields: Arc<dyn UserProfileFieldsRepository>,
|
||||
pub event_publisher: Arc<dyn EventPublisher>,
|
||||
}
|
||||
|
||||
pub struct GetSettingsDeps {
|
||||
|
||||
@@ -91,6 +91,16 @@ pub async fn execute(
|
||||
}
|
||||
});
|
||||
|
||||
let mut events = vec![DomainEvent::UserUpdated {
|
||||
user_id: user_id.clone(),
|
||||
}];
|
||||
if let Some(new_actor_url) = moved_to {
|
||||
events.push(DomainEvent::UserAccountMoved {
|
||||
user_id: user_id.clone(),
|
||||
new_actor_url,
|
||||
});
|
||||
}
|
||||
|
||||
deps.user
|
||||
.update_profile(
|
||||
&user_id,
|
||||
@@ -102,24 +112,9 @@ pub async fn execute(
|
||||
also_known_as: cmd.also_known_as,
|
||||
profile_fields: vec![],
|
||||
},
|
||||
&events,
|
||||
)
|
||||
.await?;
|
||||
|
||||
deps.event_publisher
|
||||
.publish(&DomainEvent::UserUpdated {
|
||||
user_id: user_id.clone(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
if let Some(new_actor_url) = moved_to {
|
||||
let _ = deps
|
||||
.event_publisher
|
||||
.publish(&DomainEvent::UserAccountMoved {
|
||||
user_id,
|
||||
new_actor_url,
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ pub async fn execute(
|
||||
) -> Result<(), DomainError> {
|
||||
UserProfile::validate_custom_fields(&cmd.fields)?;
|
||||
let user_id = UserId::from_uuid(cmd.user_id);
|
||||
deps.profile_fields.set_fields(&user_id, cmd.fields).await?;
|
||||
deps.event_publisher
|
||||
.publish(&DomainEvent::UserUpdated { user_id })
|
||||
.await?;
|
||||
Ok(())
|
||||
let event = DomainEvent::UserUpdated {
|
||||
user_id: user_id.clone(),
|
||||
};
|
||||
deps.profile_fields
|
||||
.set_fields(&user_id, cmd.fields, &[event])
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user