@@ -259,7 +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 ;
262+ let mut same_status = false ;
263263
264264 match order_status:: Entity :: find ( )
265265 . filter ( order_status:: Column :: OrderId . eq ( update_order. id ) )
@@ -275,7 +275,7 @@ async fn update_order(
275275 if update_order. ref_number . is_none ( ) {
276276 return ( StatusCode :: BAD_REQUEST , "Order is already in that state" ) ;
277277 }
278- dont_webhook = true ;
278+ same_status = true ;
279279 }
280280 let model = match order:: Entity :: find_by_id ( update_order. id )
281281 . one ( & state. db )
@@ -320,14 +320,16 @@ async fn update_order(
320320 . db
321321 . transaction ( |tx| {
322322 Box :: pin ( async move {
323- let active_model = order_status:: ActiveModel {
324- order_id : ActiveValue :: Set ( update_order. id ) ,
325- instance_id : ActiveValue :: NotSet ,
326- date : ActiveValue :: Set ( Local :: now ( ) . naive_local ( ) ) ,
327- status : ActiveValue :: Set ( update_order. status ) ,
328- } ;
329-
330- active_model. insert ( tx) . await ?;
323+ if !same_status {
324+ let active_model = order_status:: ActiveModel {
325+ order_id : ActiveValue :: Set ( update_order. id ) ,
326+ instance_id : ActiveValue :: NotSet ,
327+ date : ActiveValue :: Set ( Local :: now ( ) . naive_local ( ) ) ,
328+ status : ActiveValue :: Set ( update_order. status ) ,
329+ } ;
330+
331+ active_model. insert ( tx) . await ?;
332+ }
331333
332334 let active_model = order:: ActiveModel {
333335 id : ActiveValue :: Unchanged ( update_order. id ) ,
@@ -353,7 +355,7 @@ async fn update_order(
353355 error ! ( "Failed to update order status: {e}" ) ;
354356 ( StatusCode :: INTERNAL_SERVER_ERROR , "" )
355357 } else {
356- if !dont_webhook {
358+ if !same_status {
357359 state
358360 . order_updates_webhook
359361 . as_ref ( )
0 commit comments