inbox rate limiting + poster storage cleanup

This commit is contained in:
2026-05-11 01:07:21 +02:00
parent b2a2aa4262
commit 8a254346f4
11 changed files with 158 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
use crate::{commands::DeleteReviewCommand, context::AppContext};
use domain::{
errors::DomainError,
events::DomainEvent,
value_objects::{ReviewId, UserId},
};
@@ -23,7 +24,15 @@ pub async fn execute(ctx: &AppContext, cmd: DeleteReviewCommand) -> Result<(), D
let history = ctx.diary_repository.get_review_history(&movie_id).await?;
if history.viewings().is_empty() {
let poster_path = history.movie().poster_path().cloned();
ctx.movie_repository.delete_movie(&movie_id).await?;
// best-effort: movie is already deleted, so publish failure is non-fatal
if let Err(e) = ctx.event_publisher
.publish(&DomainEvent::MovieDeleted { movie_id, poster_path })
.await
{
tracing::warn!("failed to publish MovieDeleted event: {e}");
}
}
Ok(())

View File

@@ -93,6 +93,7 @@ mod tests {
DomainEvent::MovieDiscovered { .. } => "movie_discovered",
DomainEvent::ReviewLogged { .. } => "review_logged",
DomainEvent::ReviewUpdated { .. } => "review_updated",
DomainEvent::MovieDeleted { .. } => "movie_deleted",
};
self.calls.lock().unwrap().push(label);
Ok(())