Fix indempotent updates

This commit is contained in:
2025-04-19 22:23:07 +02:00
parent 2a1b1ea45a
commit f5b0ae49ca
2 changed files with 21 additions and 10 deletions

View File

@ -8,7 +8,7 @@ use actix_web::{HttpResponse, web};
/// Create a new movement
pub async fn create(auth: AuthExtractor, req: web::Json<UpdateMovementQuery>) -> HttpResult {
if let Some(err) = req.check_error(auth.user_id()).await? {
if let Some(err) = req.check_error(auth.user_id(), None).await? {
return Ok(HttpResponse::BadRequest().json(err));
}
@ -34,7 +34,10 @@ pub async fn update(
movement: MovementInPath,
req: web::Json<UpdateMovementQuery>,
) -> HttpResult {
if let Some(err) = req.check_error(auth.user_id()).await? {
if let Some(err) = req
.check_error(auth.user_id(), Some(movement.movement().id()))
.await?
{
return Ok(HttpResponse::BadRequest().json(err));
}