Skip to content

Commit cd56b1a

Browse files
committed
relaxed backend update restriction
1 parent 9f000fe commit cd56b1a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

usr-backend/src/manifest.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ async fn update_order(
259259
Json(update_order): Json<UpdateOrder>,
260260
) -> (StatusCode, &'static str) {
261261
let webhook_msg;
262+
let mut dont_webhook = false;
262263

263264
match order_status::Entity::find()
264265
.filter(order_status::Column::OrderId.eq(update_order.id))
@@ -271,7 +272,10 @@ async fn update_order(
271272
return (StatusCode::BAD_REQUEST, "Order is already in storage");
272273
}
273274
if model.status == update_order.status {
274-
return (StatusCode::BAD_REQUEST, "Order is already in that state");
275+
if update_order.ref_number.is_none() {
276+
return (StatusCode::BAD_REQUEST, "Order is already in that state");
277+
}
278+
dont_webhook = true;
275279
}
276280
let model = match order::Entity::find_by_id(update_order.id)
277281
.one(&state.db)
@@ -349,10 +353,12 @@ async fn update_order(
349353
error!("Failed to update order status: {e}");
350354
(StatusCode::INTERNAL_SERVER_ERROR, "")
351355
} else {
352-
state
353-
.order_updates_webhook
354-
.as_ref()
355-
.map(|x| x.enqueue(update_order.id, webhook_msg));
356+
if !dont_webhook {
357+
state
358+
.order_updates_webhook
359+
.as_ref()
360+
.map(|x| x.enqueue(update_order.id, webhook_msg));
361+
}
356362
backup_db(state);
357363
(StatusCode::OK, "")
358364
}

0 commit comments

Comments
 (0)