summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-25 19:13:19 +0100
committerChristian Grothoff <christian@grothoff.org>2020-10-25 19:13:19 +0100
commit1a1760c6fe08d3cf132b2bf7a45f9c9fe53a6ef2 (patch)
tree8928a79ef7a58a61e1292dd5916851a715fda0ea /src
parent369b52aac1ffe65fc3e5f915114bdb44d9211e17 (diff)
downloadmerchant-1a1760c6fe08d3cf132b2bf7a45f9c9fe53a6ef2.tar.gz
merchant-1a1760c6fe08d3cf132b2bf7a45f9c9fe53a6ef2.tar.bz2
merchant-1a1760c6fe08d3cf132b2bf7a45f9c9fe53a6ef2.zip
work on #6525
Diffstat (limited to 'src')
-rw-r--r--src/backend/taler-merchant-httpd_private-post-products.c29
1 files changed, 4 insertions, 25 deletions
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<MAX_RETRIES; i++)
{