From 5600b3868430a6d4baae628dc18f7e4ff75b12fe Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 25 Oct 2020 19:17:20 +0100 Subject: 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(-) (limited to 'src/backend') 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 60aadf4b..0c5da004 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; isession_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; -- cgit v1.2.3