From 1a1760c6fe08d3cf132b2bf7a45f9c9fe53a6ef2 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 25 Oct 2020 19:13:19 +0100 Subject: work on #6525 --- .../taler-merchant-httpd_private-post-products.c | 29 +++------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/backend/taler-merchant-httpd_private-post-products.c b/src/backend/taler-merchant-httpd_private-post-products.c index 3a35b9e6..e77690bc 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