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

@@ -23,19 +23,15 @@ pub async fn execute(
.await?;
let entry = WatchlistEntry::new(user_id.clone(), movie.id().clone());
deps.watchlist.add(&entry).await?;
let _ = deps
.event_publisher
.publish(&DomainEvent::WatchlistEntryAdded {
user_id,
movie_id: movie.id().clone(),
movie_title: movie.title().value().to_string(),
release_year: movie.release_year().value(),
external_metadata_id: movie.external_metadata_id().map(|e| e.value().to_string()),
added_at: entry.added_at,
})
.await;
let event = DomainEvent::WatchlistEntryAdded {
user_id,
movie_id: movie.id().clone(),
movie_title: movie.title().value().to_string(),
release_year: movie.release_year().value(),
external_metadata_id: movie.external_metadata_id().map(|e| e.value().to_string()),
added_at: entry.added_at,
};
deps.watchlist.add(&entry, &[event]).await?;
Ok(())
}

View File

@@ -29,5 +29,4 @@ pub struct IsOnWatchlistDeps {
pub struct RemoveFromWatchlistDeps {
pub watchlist: Arc<dyn WatchlistRepository>,
pub event_publisher: Arc<dyn EventPublisher>,
}

View File

@@ -13,12 +13,11 @@ pub async fn execute(
) -> Result<(), DomainError> {
let user_id = UserId::from_uuid(cmd.user_id);
let movie_id = MovieId::from_uuid(cmd.movie_id);
deps.watchlist.remove(&user_id, &movie_id).await?;
let _ = deps
.event_publisher
.publish(&DomainEvent::WatchlistEntryRemoved { user_id, movie_id })
.await;
let event = DomainEvent::WatchlistEntryRemoved {
user_id: user_id.clone(),
movie_id: movie_id.clone(),
};
deps.watchlist.remove(&user_id, &movie_id, &[event]).await?;
Ok(())
}