refactor: add DomainError::Forbidden + centralize error-to-HTTP mapping

Ownership checks (delete_review, confirm/dismiss watch events) now
return Forbidden instead of Unauthorized. Presentation layer maps
DomainError→StatusCode via domain_error_response helper, replacing
verbose per-handler match arms.
This commit is contained in:
2026-06-02 21:00:22 +02:00
parent 28170c95d4
commit 4067dedb28
8 changed files with 61 additions and 127 deletions

View File

@@ -25,7 +25,7 @@ pub async fn execute(ctx: &AppContext, cmd: ConfirmWatchEventsCommand) -> Result
.ok_or_else(|| DomainError::NotFound(format!("WatchEvent {}", c.watch_event_id)))?;
if event.user_id() != &user_id {
return Err(DomainError::Unauthorized("not your watch event".into()));
return Err(DomainError::Forbidden("not your watch event".into()));
}
let input = if let Some(movie_id) = event.movie_id() {

View File

@@ -27,7 +27,7 @@ pub async fn execute(ctx: &AppContext, cmd: DismissWatchEventsCommand) -> Result
}
for event in &events {
if event.user_id() != &user_id {
return Err(DomainError::Unauthorized("not your watch event".into()));
return Err(DomainError::Forbidden("not your watch event".into()));
}
}