gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated (5600b38 -> ebaa7e6)


From: gnunet
Subject: [taler-merchant] branch master updated (5600b38 -> ebaa7e6)
Date: Sun, 25 Oct 2020 19:27:45 +0100

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

grothoff pushed a change to branch master
in repository merchant.

    from 5600b38  work on #6525
     new 5efbb81  fix indent
     new ebaa7e6  work on #6525

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../taler-merchant-httpd_post-orders-ID-claim.c    |   4 +-
 .../taler-merchant-httpd_post-orders-ID-pay.c      |   4 +-
 .../taler-merchant-httpd_private-post-orders.c     | 228 +++++++++------------
 3 files changed, 97 insertions(+), 139 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 0c5da00..5580fb2 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-claim.c
@@ -170,8 +170,8 @@ TMH_post_orders_ID_claim (const struct TMH_RequestHandler 
*rh,
       GNUNET_JSON_spec_string ("nonce",
                                &nonce),
       GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_fixed_auto ("token",
-                                   &claim_token)),
+        GNUNET_JSON_spec_fixed_auto ("token",
+                                     &claim_token)),
       GNUNET_JSON_spec_end ()
     };
     enum GNUNET_GenericReturnValue res;
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 1f611e9..c5fbd05 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -1526,8 +1526,8 @@ parse_pay (struct MHD_Connection *connection,
       GNUNET_JSON_spec_json ("coins",
                              &coins),
       GNUNET_JSON_spec_mark_optional (
-      GNUNET_JSON_spec_string ("session_id",
-                               &session_id)),
+        GNUNET_JSON_spec_string ("session_id",
+                                 &session_id)),
       GNUNET_JSON_spec_end ()
     };
 
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index b355ba4..82e5e6c 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1089,16 +1089,32 @@ TMH_private_post_orders (const struct 
TMH_RequestHandler *rh,
                          struct TMH_HandlerContext *hc)
 {
   json_t *order;
-  struct GNUNET_TIME_Relative refund_delay;
+  struct GNUNET_TIME_Relative refund_delay = {
+    .rel_value_us = 0
+  };
   const char *payment_target = NULL;
+  json_t *ip = NULL;
   unsigned int ips_len = 0;
   struct InventoryProduct *ips = NULL;
   unsigned int uuids_len = 0;
+  json_t *uuid;
   struct GNUNET_Uuid *uuids = NULL;
   struct TALER_ClaimTokenP claim_token;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_json ("order",
                            &order),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("inventory_products",
+                             &ip)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("lock_uuids",
+                             &uuid)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_string ("payment_target",
+                               &payment_target)),
+    GNUNET_JSON_spec_mark_optional (
+      TALER_JSON_spec_relative_time ("refund_delay",
+                                     &refund_delay)),
     GNUNET_JSON_spec_end ()
   };
   enum GNUNET_GenericReturnValue ret;
@@ -1150,31 +1166,6 @@ TMH_private_post_orders (const struct TMH_RequestHandler 
*rh,
             0,
             sizeof (claim_token));
   }
-  /* parse the refund_delay (optionally given) */
-  if (NULL != json_object_get (hc->request_body,
-                               "refund_delay"))
-  {
-    struct GNUNET_JSON_Specification ispec[] = {
-      TALER_JSON_spec_relative_time ("refund_delay",
-                                     &refund_delay),
-      GNUNET_JSON_spec_end ()
-    };
-
-    ret = TALER_MHD_parse_json_data (connection,
-                                     hc->request_body,
-                                     ispec);
-    if (GNUNET_OK != ret)
-    {
-      GNUNET_JSON_parse_free (spec);
-      return (GNUNET_NO == ret)
-             ? MHD_YES
-             : MHD_NO;
-    }
-  }
-  else
-  {
-    refund_delay.rel_value_us = 0;
-  }
 
   /* Compute h_post_data (for idempotency check) */
   {
@@ -1207,142 +1198,109 @@ TMH_private_post_orders (const struct 
TMH_RequestHandler *rh,
     GNUNET_free (input);
   }
 
-  /* parse the payment_target (optionally given) */
+  /* parse the inventory_products (optionally given) */
+  if (NULL != ip)
   {
-    const json_t *pt;
-
-    pt = json_object_get (hc->request_body,
-                          "payment_target");
-    if (NULL != pt)
+    if (! json_is_array (ip))
     {
-      if (! json_is_string (pt))
-      {
-        GNUNET_JSON_parse_free (spec);
-        return TALER_MHD_reply_with_error (connection,
-                                           MHD_HTTP_BAD_REQUEST,
-                                           TALER_EC_PARAMETER_MALFORMED,
-                                           "payment_target");
-      }
-      payment_target = json_string_value (pt);
+      GNUNET_JSON_parse_free (spec);
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_BAD_REQUEST,
+                                         TALER_EC_PARAMETER_MALFORMED,
+                                         "inventory_products");
     }
-  }
-
-
-  /* parse the inventory_products (optionally given) */
-  {
-    const json_t *ip;
-
-    ip = json_object_get (hc->request_body,
-                          "inventory_products");
-    if (NULL != ip)
+    GNUNET_array_grow (ips,
+                       ips_len,
+                       json_array_size (ip));
+    for (unsigned int i = 0; i<ips_len; i++)
     {
-      if (! json_is_array (ip))
+      const char *error_name;
+      unsigned int error_line;
+      struct GNUNET_JSON_Specification ispec[] = {
+        GNUNET_JSON_spec_string ("product_id",
+                                 &ips[i].product_id),
+        GNUNET_JSON_spec_uint32 ("quantity",
+                                 &ips[i].quantity),
+        GNUNET_JSON_spec_end ()
+      };
+
+      ret = GNUNET_JSON_parse (json_array_get (ip,
+                                               i),
+                               ispec,
+                               &error_name,
+                               &error_line);
+      if (GNUNET_OK != ret)
       {
+        GNUNET_break_op (0);
+        GNUNET_array_grow (ips,
+                           ips_len,
+                           0);
+        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                    "Product parsing failed at #%u: %s:%u\n",
+                    i,
+                    error_name,
+                    error_line);
         GNUNET_JSON_parse_free (spec);
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_BAD_REQUEST,
                                            TALER_EC_PARAMETER_MALFORMED,
                                            "inventory_products");
       }
-      GNUNET_array_grow (ips,
-                         ips_len,
-                         json_array_size (ip));
-      for (unsigned int i = 0; i<ips_len; i++)
-      {
-        const char *error_name;
-        unsigned int error_line;
-        struct GNUNET_JSON_Specification ispec[] = {
-          GNUNET_JSON_spec_string ("product_id",
-                                   &ips[i].product_id),
-          GNUNET_JSON_spec_uint32 ("quantity",
-                                   &ips[i].quantity),
-          GNUNET_JSON_spec_end ()
-        };
-
-        ret = GNUNET_JSON_parse (json_array_get (ip,
-                                                 i),
-                                 ispec,
-                                 &error_name,
-                                 &error_line);
-        if (GNUNET_OK != ret)
-        {
-          GNUNET_break_op (0);
-          GNUNET_array_grow (ips,
-                             ips_len,
-                             0);
-          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                      "Product parsing failed at #%u: %s:%u\n",
-                      i,
-                      error_name,
-                      error_line);
-          GNUNET_JSON_parse_free (spec);
-          return TALER_MHD_reply_with_error (connection,
-                                             MHD_HTTP_BAD_REQUEST,
-                                             TALER_EC_PARAMETER_MALFORMED,
-                                             "inventory_products");
-        }
-      }
     }
   }
 
   /* parse the lock_uuids (optionally given) */
+  if (NULL != uuid)
   {
-    const json_t *uuid;
-
-    uuid = json_object_get (hc->request_body,
-                            "lock_uuids");
-    if (NULL != uuid)
+    if (! json_is_array (uuid))
+    {
+      GNUNET_array_grow (ips,
+                         ips_len,
+                         0);
+      GNUNET_JSON_parse_free (spec);
+      return TALER_MHD_reply_with_error (connection,
+                                         MHD_HTTP_BAD_REQUEST,
+                                         TALER_EC_PARAMETER_MALFORMED,
+                                         "lock_uuids");
+    }
+    GNUNET_array_grow (uuids,
+                       uuids_len,
+                       json_array_size (uuid));
+    for (unsigned int i = 0; i<uuids_len; i++)
     {
-      if (! json_is_array (uuid))
+      const char *error_name;
+      unsigned int error_line;
+      struct GNUNET_JSON_Specification ispec[] = {
+        GNUNET_JSON_spec_fixed_auto ("uuid",
+                                     &uuids[i]),
+        GNUNET_JSON_spec_end ()
+      };
+
+      ret = GNUNET_JSON_parse (json_array_get (uuid,
+                                               i),
+                               ispec,
+                               &error_name,
+                               &error_line);
+      if (GNUNET_OK != ret)
       {
+        GNUNET_break_op (0);
         GNUNET_array_grow (ips,
                            ips_len,
                            0);
+        GNUNET_array_grow (uuids,
+                           uuids_len,
+                           0);
+        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                    "UUID parsing failed at #%u: %s:%u\n",
+                    i,
+                    error_name,
+                    error_line);
         GNUNET_JSON_parse_free (spec);
         return TALER_MHD_reply_with_error (connection,
                                            MHD_HTTP_BAD_REQUEST,
                                            TALER_EC_PARAMETER_MALFORMED,
                                            "lock_uuids");
       }
-      GNUNET_array_grow (uuids,
-                         uuids_len,
-                         json_array_size (uuid));
-      for (unsigned int i = 0; i<uuids_len; i++)
-      {
-        const char *error_name;
-        unsigned int error_line;
-        struct GNUNET_JSON_Specification ispec[] = {
-          GNUNET_JSON_spec_fixed_auto ("uuid",
-                                       &uuids[i]),
-          GNUNET_JSON_spec_end ()
-        };
-
-        ret = GNUNET_JSON_parse (json_array_get (uuid,
-                                                 i),
-                                 ispec,
-                                 &error_name,
-                                 &error_line);
-        if (GNUNET_OK != ret)
-        {
-          GNUNET_break_op (0);
-          GNUNET_array_grow (ips,
-                             ips_len,
-                             0);
-          GNUNET_array_grow (uuids,
-                             uuids_len,
-                             0);
-          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                      "UUID parsing failed at #%u: %s:%u\n",
-                      i,
-                      error_name,
-                      error_line);
-          GNUNET_JSON_parse_free (spec);
-          return TALER_MHD_reply_with_error (connection,
-                                             MHD_HTTP_BAD_REQUEST,
-                                             TALER_EC_PARAMETER_MALFORMED,
-                                             "lock_uuids");
-        }
-      }
     }
   }
 

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