gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] 03/03: work on #6525


From: gnunet
Subject: [taler-merchant] 03/03: work on #6525
Date: Sun, 25 Oct 2020 19:17:27 +0100

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

grothoff pushed a commit to branch master
in repository merchant.

commit 5600b3868430a6d4baae628dc18f7e4ff75b12fe
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Oct 25 19:17:20 2020 +0100

    work on #6525
---
 .../taler-merchant-httpd_post-orders-ID-claim.c    | 27 ++-----------
 .../taler-merchant-httpd_post-orders-ID-pay.c      | 47 ++++++++--------------
 2 files changed, 19 insertions(+), 55 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
index 60aadf4..0c5da00 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
@@ -163,30 +163,15 @@ TMH_post_orders_ID_claim (const struct TMH_RequestHandler 
*rh,
   const char *nonce;
   enum GNUNET_DB_QueryStatus qs;
   json_t *contract_terms;
-  struct TALER_ClaimTokenP claim_token;
+  struct TALER_ClaimTokenP claim_token = { 0 };
 
   {
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_string ("nonce",
                                &nonce),
-      GNUNET_JSON_spec_end ()
-    };
-    enum GNUNET_GenericReturnValue res;
-
-    res = TALER_MHD_parse_json_data (connection,
-                                     hc->request_body,
-                                     spec);
-    if (GNUNET_OK != res)
-      return (GNUNET_NO == res)
-             ? MHD_YES
-             : MHD_NO;
-  }
-  if (NULL != json_object_get (hc->request_body,
-                               "token"))
-  {
-    struct GNUNET_JSON_Specification spec[] = {
+      GNUNET_JSON_spec_mark_optional (
       GNUNET_JSON_spec_fixed_auto ("token",
-                                   &claim_token),
+                                   &claim_token)),
       GNUNET_JSON_spec_end ()
     };
     enum GNUNET_GenericReturnValue res;
@@ -199,12 +184,6 @@ TMH_post_orders_ID_claim (const struct TMH_RequestHandler 
*rh,
              ? MHD_YES
              : MHD_NO;
   }
-  else
-  {
-    memset (&claim_token,
-            0,
-            sizeof (claim_token));
-  }
   contract_terms = NULL;
   for (unsigned int i = 0; i<MAX_RETRIES; i++)
   {
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index f33aa9d..1f611e9 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -1280,6 +1280,7 @@ check_payment_sufficient (struct PayContext *pc)
   return true;
 }
 
+
 static void
 begin_transaction (struct PayContext *pc)
 {
@@ -1519,10 +1520,14 @@ parse_pay (struct MHD_Connection *connection,
 {
   /* First, parse request */
   {
+    const char *session_id = NULL;
     json_t *coins;
     struct GNUNET_JSON_Specification spec[] = {
       GNUNET_JSON_spec_json ("coins",
                              &coins),
+      GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_string ("session_id",
+                               &session_id)),
       GNUNET_JSON_spec_end ()
     };
 
@@ -1539,6 +1544,17 @@ parse_pay (struct MHD_Connection *connection,
       }
     }
 
+    /* copy session ID (if set) */
+    if (NULL != session_id)
+    {
+      pc->session_id = GNUNET_strdup (session_id);
+    }
+    else
+    {
+      /* use empty string as default if client didn't specify it */
+      pc->session_id = GNUNET_strdup ("");
+    }
+
     if ( (! json_is_array (coins)) ||
          (0 == (pc->coins_cnt = json_array_size (coins))) )
     {
@@ -1596,37 +1612,6 @@ parse_pay (struct MHD_Connection *connection,
     GNUNET_JSON_parse_free (spec);
   }
 
-  /* copy session ID (if set) */
-  {
-    const char *session_id;
-    json_t *sid;
-
-    sid = json_object_get (hc->request_body,
-                           "session_id");
-    if (NULL != sid)
-    {
-      if (! json_is_string (sid))
-      {
-        GNUNET_break_op (0);
-        return (MHD_YES ==
-                TALER_MHD_reply_with_error (connection,
-                                            MHD_HTTP_BAD_REQUEST,
-                                            TALER_EC_PARAMETER_MALFORMED,
-                                            "session_id"))
-               ? GNUNET_NO
-               : GNUNET_SYSERR;
-      }
-      session_id = json_string_value (sid);
-      GNUNET_assert (NULL != session_id);
-      pc->session_id = GNUNET_strdup (session_id);
-    }
-    else
-    {
-      /* use empty string as default if client didn't specify it */
-      pc->session_id = GNUNET_strdup ("");
-    }
-  }
-
   /* copy order ID */
   {
     const char *order_id = hc->infix;

-- 
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]