aboutsummaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-08-22 22:47:41 +0200
committerChristian Grothoff <christian@grothoff.org>2022-08-22 22:47:41 +0200
commitb14e18eb31c957276c3f74834495d1bfa5c9329a (patch)
treebbde2d22eb1069607dcce675a5c39a276663b06b /src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
parent1a62744325edc68e106b806ede0ac418d880ca4f (diff)
-fix misc clang compiler warnings
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c109
1 files changed, 75 insertions, 34 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
index 0709679b..10c76013 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -433,6 +433,54 @@ handle_kyc_timeout (void *cls)
/**
+ * We are done with the KYC request @a ekr.
+ * Remove it from the work list and check if
+ * we are done overall.
+ *
+ * @param[in] ekr key request that is done (and will be freed)
+ */
+static void
+ekr_finished (struct ExchangeKycRequest *ekr)
+{
+ struct KycContext *kc = ekr->kc;
+
+ GNUNET_CONTAINER_DLL_remove (kc->exchange_pending_head,
+ kc->exchange_pending_tail,
+ ekr);
+ GNUNET_free (ekr->exchange_url);
+ GNUNET_free (ekr->payto_uri);
+ GNUNET_free (ekr);
+ if (NULL != kc->exchange_pending_head)
+ return; /* wait for more */
+ /* All exchange requests done, create final
+ big response from cummulated replies */
+ if ( (0 == json_array_size (kc->pending_kycs)) &&
+ (0 == json_array_size (kc->timeout_kycs)) )
+ {
+ /* special case: all KYC operations did succeed
+ after we asked at the exchanges => 204 */
+ struct MHD_Response *response;
+
+ response = MHD_create_response_from_buffer (0,
+ "",
+ MHD_RESPMEM_PERSISTENT);
+ resume_kyc_with_response (kc,
+ MHD_HTTP_NO_CONTENT,
+ response);
+ return;
+ }
+ resume_kyc_with_response (
+ kc,
+ kc->response_code, /* MHD_HTTP_OK or MHD_HTTP_BAD_GATEWAY */
+ TALER_MHD_MAKE_JSON_PACK (
+ GNUNET_JSON_pack_array_incref ("pending_kycs",
+ kc->pending_kycs),
+ GNUNET_JSON_pack_array_incref ("timeout_kycs",
+ kc->timeout_kycs)));
+}
+
+
+/**
* Function called with the result of a KYC check.
*
* @param cls a `struct ExchangeKycRequest *`
@@ -520,41 +568,8 @@ exchange_check_cb (void *cls,
ks->ec),
GNUNET_JSON_pack_uint64 ("exchange_http_status",
ks->http_status))));
- break;
- }
- GNUNET_CONTAINER_DLL_remove (kc->exchange_pending_head,
- kc->exchange_pending_tail,
- ekr);
- GNUNET_free (ekr->exchange_url);
- GNUNET_free (ekr->payto_uri);
- GNUNET_free (ekr);
- if (NULL != kc->exchange_pending_head)
- return; /* wait for more */
- /* All exchange requests done, create final
- big response from cummulated replies */
- if ( (0 == json_array_size (kc->pending_kycs)) &&
- (0 == json_array_size (kc->timeout_kycs)) )
- {
- /* special case: all KYC operations did succeed
- after we asked at the exchanges => 204 */
- struct MHD_Response *response;
-
- response = MHD_create_response_from_buffer (0,
- "",
- MHD_RESPMEM_PERSISTENT);
- resume_kyc_with_response (kc,
- MHD_HTTP_NO_CONTENT,
- response);
- return;
}
- resume_kyc_with_response (
- kc,
- kc->response_code, /* MHD_HTTP_OK or MHD_HTTP_BAD_GATEWAY */
- TALER_MHD_MAKE_JSON_PACK (
- GNUNET_JSON_pack_array_incref ("pending_kycs",
- kc->pending_kycs),
- GNUNET_JSON_pack_array_incref ("timeout_kycs",
- kc->timeout_kycs)));
+ ekr_finished (ekr);
}
@@ -581,7 +596,31 @@ kyc_with_exchange (void *cls,
struct KycContext *kc = ekr->kc;
struct TALER_PaytoHashP h_payto;
+ (void) payto_uri;
+ (void) wire_fee;
+ (void) exchange_trusted;
ekr->fo = NULL;
+ if (MHD_HTTP_OK != hr->http_status)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Exchange responded with HTTP status %u (%d) to /kyc-check request!\n",
+ hr->http_status,
+ hr->ec);
+ kc->response_code = MHD_HTTP_BAD_GATEWAY;
+ GNUNET_assert (
+ 0 ==
+ json_array_append_new (
+ kc->timeout_kycs,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("exchange_url",
+ ekr->exchange_url),
+ GNUNET_JSON_pack_uint64 ("exchange_code",
+ hr->ec),
+ GNUNET_JSON_pack_uint64 ("exchange_http_status",
+ hr->http_status))));
+ ekr_finished (ekr);
+ return;
+ }
TALER_payto_hash (ekr->payto_uri,
&h_payto);
ekr->kyc = TALER_EXCHANGE_kyc_check (
@@ -832,6 +871,7 @@ TMH_private_get_instances_ID_kyc (const struct TMH_RequestHandler *rh,
{
struct TMH_MerchantInstance *mi = hc->instance;
+ (void) rh;
return get_instances_ID_kyc (mi,
connection,
hc);
@@ -845,6 +885,7 @@ TMH_private_get_instances_default_ID_kyc (const struct TMH_RequestHandler *rh,
{
struct TMH_MerchantInstance *mi;
+ (void) rh;
mi = TMH_lookup_instance (hc->infix);
if (NULL == mi)
{