commit 74837ec5fb601f503fc2fc2f284c3d8cd384f01d
parent 686809abbdfcd7dcb8171044387b0c536caa043e
Author: Florian Dold <florian@dold.me>
Date: Mon, 21 Oct 2024 16:25:35 +0200
return 202 from /kyc-info when instant measure is running
Diffstat:
1 file changed, 54 insertions(+), 0 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c b/src/exchange/taler-exchange-httpd_kyc-info.c
@@ -342,6 +342,51 @@ generate_reply (struct KycPoller *kyp,
}
+/**
+ * Check if measures contain an instant
+ * measure.
+ *
+ * @param jmeasures measures JSON object
+ * @returns true if @a jmeasures contains an instant measure
+ */
+bool
+contains_instant_measure (const json_t *jmeasures)
+{
+ size_t i;
+ json_t *mi; /* a MeasureInformation object */
+ const char *ename;
+ unsigned int eline;
+ enum GNUNET_GenericReturnValue ret;
+
+ json_array_foreach ((json_t *) jmeasures, i, mi)
+ {
+ const char *check_name;
+
+ struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_string ("check_name",
+ &check_name),
+ GNUNET_JSON_spec_end ()
+ };
+
+ ret = GNUNET_JSON_parse (mi,
+ ispec,
+ &ename,
+ &eline);
+ if (GNUNET_OK != ret)
+ {
+ GNUNET_break (0);
+ continue;
+ }
+ if (0 == strcasecmp (check_name, "SKIP"))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
MHD_RESULT
TEH_handler_kyc_info (
struct TEH_RequestContext *rc,
@@ -550,6 +595,15 @@ TEH_handler_kyc_info (
MHD_suspend_connection (rc->connection);
return MHD_YES;
}
+ if (contains_instant_measure (jmeasures))
+ {
+ json_decref (jmeasures);
+ json_decref (jvoluntary);
+ return TALER_MHD_reply_with_ec (
+ rc->connection,
+ TALER_EC_EXCHANGE_KYC_INFO_BUSY,
+ "waiting for KYC program");
+ }
if ( (legitimization_measure_last_row ==
kyp->etag_measure_in) &&
(legitimization_outcome_last_row ==