gnunet-svn
[Top][All Lists]
Advanced

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

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


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

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

grothoff pushed a change to branch master
in repository merchant.

    from d68f76b  fix spelling
     new 369b52a  indentation fixes
     new 1a1760c  work on #6525
     new 5600b38  work on #6525

The 3 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:
 src/backend/taler-merchant-httpd_auditors.c        |  1 +
 src/backend/taler-merchant-httpd_exchanges.c       |  4 ++
 .../taler-merchant-httpd_post-orders-ID-abort.c    |  1 +
 .../taler-merchant-httpd_post-orders-ID-claim.c    | 27 ++-----------
 .../taler-merchant-httpd_post-orders-ID-pay.c      | 47 ++++++++--------------
 .../taler-merchant-httpd_private-get-tips.c        |  1 +
 .../taler-merchant-httpd_private-post-products.c   | 29 ++-----------
 src/lib/merchant_api_post_order_claim.c            |  3 +-
 src/lib/merchant_api_post_orders.c                 |  8 ++--
 .../testing_api_cmd_wallet_post_orders_refund.c    |  3 +-
 10 files changed, 38 insertions(+), 86 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_auditors.c 
b/src/backend/taler-merchant-httpd_auditors.c
index 1609e2b..c7e7e58 100644
--- a/src/backend/taler-merchant-httpd_auditors.c
+++ b/src/backend/taler-merchant-httpd_auditors.c
@@ -216,6 +216,7 @@ parse_auditors (void *cls,
                        auditor);
 }
 
+
 int
 TMH_AUDITORS_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
diff --git a/src/backend/taler-merchant-httpd_exchanges.c 
b/src/backend/taler-merchant-httpd_exchanges.c
index 1d5db7e..e882f55 100644
--- a/src/backend/taler-merchant-httpd_exchanges.c
+++ b/src/backend/taler-merchant-httpd_exchanges.c
@@ -604,6 +604,7 @@ process_find_operations (struct Exchange *exchange)
   return need_wire;
 }
 
+
 static void
 wire_task_cb (void *cls);
 
@@ -940,6 +941,7 @@ return_result (void *cls)
   }
 }
 
+
 struct TMH_EXCHANGES_FindOperation *
 TMH_EXCHANGES_find_exchange (const char *chosen_exchange,
                              const char *wire_method,
@@ -1169,6 +1171,7 @@ accept_exchanges (void *cls,
                                                    exchange);
 }
 
+
 int
 TMH_EXCHANGES_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
@@ -1208,6 +1211,7 @@ TMH_EXCHANGES_init (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
   return json_array_size (TMH_trusted_exchanges);
 }
 
+
 void
 TMH_EXCHANGES_done ()
 {
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
index 58c38b7..cfb5bb7 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-abort.c
@@ -257,6 +257,7 @@ abort_refunds (struct AbortContext *ac)
   }
 }
 
+
 void
 TMH_force_ac_resume ()
 {
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;
diff --git a/src/backend/taler-merchant-httpd_private-get-tips.c 
b/src/backend/taler-merchant-httpd_private-get-tips.c
index 74b9751..4282ebe 100644
--- a/src/backend/taler-merchant-httpd_private-get-tips.c
+++ b/src/backend/taler-merchant-httpd_private-get-tips.c
@@ -51,6 +51,7 @@ add_tip (void *cls,
                      TALER_JSON_from_amount (&amount))));
 }
 
+
 MHD_RESULT
 TMH_private_get_tips (const struct TMH_RequestHandler *rh,
                       struct MHD_Connection *connection,
diff --git a/src/backend/taler-merchant-httpd_private-post-products.c 
b/src/backend/taler-merchant-httpd_private-post-products.c
index 3a35b9e..e77690b 100644
--- a/src/backend/taler-merchant-httpd_private-post-products.c
+++ b/src/backend/taler-merchant-httpd_private-post-products.c
@@ -74,7 +74,7 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
                            struct TMH_HandlerContext *hc)
 {
   struct TMH_MerchantInstance *mi = hc->instance;
-  struct TALER_MERCHANTDB_ProductDetails pd;
+  struct TALER_MERCHANTDB_ProductDetails pd = { 0 };
   const char *product_id;
   int64_t total_stock;
   enum GNUNET_DB_QueryStatus qs;
@@ -85,6 +85,9 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
                              (const char **) &pd.description),
     GNUNET_JSON_spec_json ("description_i18n",
                            &pd.description_i18n),
+    GNUNET_JSON_spec_mark_optional (
+      TALER_JSON_spec_absolute_time ("next_restock",
+                                     &pd.next_restock)),
     GNUNET_JSON_spec_string ("unit",
                              (const char **) &pd.unit),
     TALER_JSON_spec_amount ("price",
@@ -109,8 +112,6 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
     res = TALER_MHD_parse_json_data (connection,
                                      hc->request_body,
                                      spec);
-    pd.total_sold = 0;
-    pd.total_lost = 0;
     if (GNUNET_OK != res)
       return (GNUNET_NO == res)
              ? MHD_YES
@@ -121,28 +122,6 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
     pd.total_stock = UINT64_MAX;
   else
     pd.total_stock = (uint64_t) total_stock;
-  if (NULL != json_object_get (hc->request_body,
-                               "next_restock"))
-  {
-    enum GNUNET_GenericReturnValue res;
-    struct GNUNET_JSON_Specification spec[] = {
-      TALER_JSON_spec_absolute_time ("next_restock",
-                                     &pd.next_restock),
-      GNUNET_JSON_spec_end ()
-    };
-
-    res = TALER_MHD_parse_json_data (connection,
-                                     hc->request_body,
-                                     spec);
-    if (GNUNET_OK != res)
-      return (GNUNET_NO == res)
-             ? MHD_YES
-             : MHD_NO;
-  }
-  else
-  {
-    pd.next_restock.abs_value_us = 0;
-  }
 
   for (unsigned int i = 0; i<MAX_RETRIES; i++)
   {
diff --git a/src/lib/merchant_api_post_order_claim.c 
b/src/lib/merchant_api_post_order_claim.c
index 1389d8e..f37e597 100644
--- a/src/lib/merchant_api_post_order_claim.c
+++ b/src/lib/merchant_api_post_order_claim.c
@@ -190,7 +190,8 @@ TALER_MERCHANT_order_claim (struct GNUNET_CURL_Context *ctx,
     GNUNET_assert (0 ==
                    json_object_set_new (req_obj,
                                         "token",
-                                        GNUNET_JSON_from_data_auto 
(claim_token)));
+                                        GNUNET_JSON_from_data_auto (
+                                          claim_token)));
   }
   och = GNUNET_new (struct TALER_MERCHANT_OrderClaimHandle);
   och->ctx = ctx;
diff --git a/src/lib/merchant_api_post_orders.c 
b/src/lib/merchant_api_post_orders.c
index baab8ac..20af444 100644
--- a/src/lib/merchant_api_post_orders.c
+++ b/src/lib/merchant_api_post_orders.c
@@ -100,10 +100,10 @@ handle_post_order_finished (void *cls,
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("order_id",
                              &order_id),
-    (!has_token) ?
-      GNUNET_JSON_spec_end () :
-      GNUNET_JSON_spec_fixed_auto ("token",
-                                   &token),
+    (! has_token) ?
+    GNUNET_JSON_spec_end () :
+    GNUNET_JSON_spec_fixed_auto ("token",
+                                 &token),
     GNUNET_JSON_spec_end ()
   };
 
diff --git a/src/testing/testing_api_cmd_wallet_post_orders_refund.c 
b/src/testing/testing_api_cmd_wallet_post_orders_refund.c
index 912264a..80e5e99 100644
--- a/src/testing/testing_api_cmd_wallet_post_orders_refund.c
+++ b/src/testing/testing_api_cmd_wallet_post_orders_refund.c
@@ -138,7 +138,8 @@ refund_cb (
         /* The most recent refunds are returned first */
         GNUNET_assert (0 <= TALER_amount_add (&refunded_total,
                                               &refunded_total,
-                                              &refunds[refunds_length - 1 - 
i].refund_amount));
+                                              &refunds[refunds_length - 1
+                                                       - i].refund_amount));
         if ((GNUNET_OK !=
              TALER_amount_cmp_currency (&expected_amount,
                                         &refunded_total)) ||

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