gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] 01/04: properly detect if CONTRACT with same order ID a


From: gnunet
Subject: [taler-merchant] 01/04: properly detect if CONTRACT with same order ID already exists as well
Date: Sat, 31 Oct 2020 00:50:55 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

commit 9a27496913724498df3db912ea1cbda6c80f8cc2
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Oct 30 23:38:37 2020 +0100

    properly detect if CONTRACT with same order ID already exists as well
---
 .../taler-merchant-httpd_private-post-orders.c     | 25 ++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 8411420..bac98d4 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -218,6 +218,17 @@ execute_transaction (struct TMH_HandlerContext *hc,
     GNUNET_break (0);
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
+  qs = TMH_db->lookup_order_summary (TMH_db->cls,
+                                     hc->instance->settings.id,
+                                     order_id,
+                                     &timestamp,
+                                     &order_serial);
+  if (0 != qs)
+  {
+    /* order already exists. */
+    TMH_db->rollback (TMH_db->cls);
+    return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
+  }
   /* Setup order */
   qs = TMH_db->insert_order (TMH_db->cls,
                              hc->instance->settings.id,
@@ -226,11 +237,11 @@ execute_transaction (struct TMH_HandlerContext *hc,
                              pay_deadline,
                              claim_token,
                              order);
-  /* qs == 0: order already exists. */
+  /* qs == 0: probably instance does not exist. */
   if (qs <= 0)
   {
     TMH_db->rollback (TMH_db->cls);
-    return qs;
+    return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
   }
   /* Migrate locks from UUIDs to new order: first release old locks */
   for (unsigned int i = 0; i<uuids_length; i++)
@@ -508,6 +519,16 @@ execute_order (struct MHD_Connection *connection,
                                          NULL);
     }
 
+    if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+    {
+      /* should be: contract (!) with same order ID
+         already exists */
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_CONFLICT,
+                                         
TALER_EC_PROPOSAL_STORE_DB_ERROR_ALREADY_EXISTS,
+                                         order_id);
+    }
+
     /* If we have a product that has insufficient quantities,
        generate the details for the response. */
     if (PRODUCT_OOS_OFFSET >= qs)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]