aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-11-12 23:36:55 +0100
committerChristian Grothoff <christian@grothoff.org>2024-11-12 23:36:55 +0100
commit795faaf14b4a8c010edc5f524f55bec4131b9a78 (patch)
treeacfa868ec310f2bc8d3575810e00fcf2b69812d9
parent1a3e1817fd06bba941cfa73ecd1c91600ba37f52 (diff)
implement #9217
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c78
1 files changed, 78 insertions, 0 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 0ccee818..f667c886 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
@@ -513,6 +513,73 @@ get_exchange_limits (
/**
+ * Maps @a ekr to a status code for clients to interpret the
+ * overall result.
+ *
+ * @param ekr request summary
+ * @return status of the KYC state as a string
+ */
+static const char *
+map_to_status (const struct ExchangeKycRequest *ekr)
+{
+ if (ekr->no_keys)
+ {
+ return "no-exchange-keys";
+ }
+ if (ekr->kyc_ok)
+ {
+ return "ready";
+ }
+ if (! ekr->auth_ok)
+ {
+ if (ekr->kyc_auth_conflict)
+ return "kyc-wire-impossible";
+ return "kyc-wire-required";
+ }
+ if (ekr->in_aml_review)
+ return "awaiting-aml-review";
+ switch (ekr->last_http_status)
+ {
+ case 0:
+ return "exchange-unreachable";
+ case MHD_HTTP_OK:
+ /* then whe should have kyc_ok */
+ GNUNET_break (0);
+ return NULL;
+ case MHD_HTTP_ACCEPTED:
+ /* Then KYC is really what is needed */
+ return "kyc-required";
+ case MHD_HTTP_NO_CONTENT:
+ /* then whe should have had kyc_ok! */
+ GNUNET_break (0);
+ return NULL;
+ case MHD_HTTP_FORBIDDEN:
+ /* then whe should have had ! auth_ok */
+ GNUNET_break (0);
+ return NULL;
+ case MHD_HTTP_NOT_FOUND:
+ /* then whe should have had ! auth_ok */
+ GNUNET_break (0);
+ return NULL;
+ case MHD_HTTP_CONFLICT:
+ /* then whe should have had ! auth_ok */
+ GNUNET_break (0);
+ return NULL;
+ case MHD_HTTP_INTERNAL_SERVER_ERROR:
+ return "exchange-internal-error";
+ case MHD_HTTP_GATEWAY_TIMEOUT:
+ return "exchange-gateway-timeout";
+ default:
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Exchange responded with unexpected HTTP status %u to /kyc-check request!\n",
+ ekr->last_http_status);
+ break;
+ }
+ return "exchange-status-invalid";
+}
+
+
+/**
* Take data from @a ekr to expand our response.
*
* @param ekr exchange we are done inspecting
@@ -520,6 +587,14 @@ get_exchange_limits (
static void
ekr_expand_response (struct ExchangeKycRequest *ekr)
{
+ const char *status;
+
+ status = map_to_status (ekr);
+ if (NULL == status)
+ {
+ GNUNET_break (0);
+ status = "logic-bug";
+ }
GNUNET_assert (
0 ==
json_array_append_new (
@@ -532,6 +607,9 @@ ekr_expand_response (struct ExchangeKycRequest *ekr)
"h_wire",
&ekr->h_wire),
GNUNET_JSON_pack_string (
+ "status",
+ status),
+ GNUNET_JSON_pack_string (
"exchange_url",
ekr->exchange_url),
GNUNET_JSON_pack_bool ("no_keys",