aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-01-27 14:19:14 +0100
committerChristian Grothoff <christian@grothoff.org>2023-01-27 14:19:14 +0100
commit42bd2dadcfad336623c0650c28580e8206bf95b9 (patch)
tree947a8777e0bc5651fe46c72736838ea43d781be9 /src
parentc239ba6f18ee7d62b249c7204dbe50dab37912b8 (diff)
downloadexchange-42bd2dadcfad336623c0650c28580e8206bf95b9.tar.xz
address DB failure error handling in KYC check
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-check.c27
-rw-r--r--src/include/taler_kyclogic_lib.h10
-rw-r--r--src/kyclogic/kyclogic_api.c20
3 files changed, 42 insertions, 15 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c b/src/exchange/taler-exchange-httpd_kyc-check.c
index 47338ae96..1ef12bd95 100644
--- a/src/exchange/taler-exchange-httpd_kyc-check.c
+++ b/src/exchange/taler-exchange-httpd_kyc-check.c
@@ -297,6 +297,7 @@ kyc_check (void *cls,
enum GNUNET_GenericReturnValue ret;
struct TALER_PaytoHashP h_payto;
char *requirements;
+ bool satisfied;
qs = TEH_plugin->lookup_kyc_requirement_by_row (
TEH_plugin->cls,
@@ -330,12 +331,26 @@ kyc_check (void *cls,
GNUNET_free (requirements);
return GNUNET_DB_STATUS_HARD_ERROR;
}
- if (TALER_KYCLOGIC_check_satisfied (
- requirements,
- &h_payto,
- &kyp->kyc_details,
- TEH_plugin->select_satisfied_kyc_processes,
- TEH_plugin->cls))
+ qs = TALER_KYCLOGIC_check_satisfied (
+ requirements,
+ &h_payto,
+ &kyp->kyc_details,
+ TEH_plugin->select_satisfied_kyc_processes,
+ TEH_plugin->cls,
+ &satisfied);
+ if (qs < 0)
+ {
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ return qs;
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "kyc_test_required");
+ GNUNET_free (requirements);
+ return GNUNET_DB_STATUS_HARD_ERROR;
+ }
+ if (satisfied)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"KYC requirements `%s' already satisfied\n",
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index 3acc78df2..e90dcb1c2 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -214,7 +214,7 @@ typedef enum GNUNET_DB_QueryStatus
* amounts involved in this type of operation
* at the given account
* @param ai_cls closure for @a ai
- * @param[out] set to NULL if no check is needed,
+ * @param[out] required set to NULL if no check is needed,
* otherwise space-separated list of required checks
* @return transaction status
*/
@@ -238,14 +238,16 @@ TALER_KYCLOGIC_kyc_test_required (enum TALER_KYCLOGIC_KycTriggerEvent event,
* KYC information was collected
* @param ki iterator over satisfied providers
* @param ki_cls closure for @a ki
- * @return true if the KYC check was satisfied
+ * @param[out] satisfied set to true if the KYC check was satisfied
+ * @return transaction status (from @a ki)
*/
-bool
+enum GNUNET_DB_QueryStatus
TALER_KYCLOGIC_check_satisfied (const char *requirements,
const struct TALER_PaytoHashP *h_payto,
json_t **kyc_details,
TALER_KYCLOGIC_KycSatisfiedIterator ki,
- void *ki_cls);
+ void *ki_cls,
+ bool *satisfied);
/**
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index fdd814ae0..d7ecf51e1 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -1166,18 +1166,22 @@ TALER_KYCLOGIC_kyc_get_details (
}
-bool
+enum GNUNET_DB_QueryStatus
TALER_KYCLOGIC_check_satisfied (const char *requirements,
const struct TALER_PaytoHashP *h_payto,
json_t **kyc_details,
TALER_KYCLOGIC_KycSatisfiedIterator ki,
- void *ki_cls)
+ void *ki_cls,
+ bool *satisfied)
{
struct TALER_KYCLOGIC_KycCheck *needed[num_kyc_checks];
unsigned int needed_cnt = 0;
if (NULL == requirements)
- return true;
+ {
+ *satisfied = true;
+ return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS;
+ }
{
char *req = GNUNET_strdup (requirements);
@@ -1204,7 +1208,12 @@ TALER_KYCLOGIC_check_satisfied (const char *requirements,
h_payto,
&remove_satisfied,
&rc);
- GNUNET_break (qs >= 0); // FIXME: handle DB failure more nicely?
+ if (qs < 0)
+ {
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
+ *satisfied = false;
+ return qs;
+ }
if (0 != needed_cnt)
{
json_decref (rc.kyc_details);
@@ -1215,7 +1224,8 @@ TALER_KYCLOGIC_check_satisfied (const char *requirements,
*kyc_details = rc.kyc_details;
}
}
- return (0 == needed_cnt);
+ *satisfied = (0 == needed_cnt);
+ return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
}