feat: atomic goal, watchlist, profile writes

This commit is contained in:
2026-10-26 00:49:28 +01:00
parent c8a1e8bfe4
commit 62ad9f4017
48 changed files with 1296 additions and 264 deletions

View File

@@ -161,8 +161,14 @@ impl UserRepository for SqliteUserRepository {
&self,
user_id: &UserId,
profile: &domain::models::UserProfile,
events: &[domain::events::DomainEvent],
) -> Result<(), DomainError> {
let id_str = user_id.value().to_string();
let mut tx = self
.pool
.begin()
.await
.map_err(crate::shared::map_sqlx_error)?;
sqlx::query(
"UPDATE users SET display_name = ?, bio = ?, avatar_path = ?, banner_path = ?, also_known_as = ? WHERE id = ?",
)
@@ -172,10 +178,11 @@ impl UserRepository for SqliteUserRepository {
.bind(&profile.banner_path)
.bind(&profile.also_known_as)
.bind(&id_str)
.execute(&self.pool)
.execute(&mut *tx)
.await
.map_err(|e| DomainError::InfrastructureError(e.to_string()))?;
Ok(())
crate::shared::enqueue_events(&mut tx, events).await?;
tx.commit().await.map_err(crate::shared::map_sqlx_error)
}
async fn list_with_stats(&self) -> Result<Vec<domain::models::UserSummary>, DomainError> {