aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-10-31 11:43:06 +0100
committerFlorian Dold <florian@dold.me>2024-10-31 14:11:27 +0100
commit97a767743cbbad2886d285f2885d3761bcb58d4a (patch)
treeea6ea1216e10a4fc9f1f395e26b7c1ac9fab06ef
parent2684bbee26d4408f20b1fbe8540d483e0925ac46 (diff)
only insert kyc_attributes if there is a process row
-rw-r--r--src/exchange/taler-exchange-httpd_common_kyc.c2
-rw-r--r--src/exchangedb/exchange_do_insert_kyc_attributes.sql31
-rw-r--r--src/exchangedb/pg_insert_kyc_attributes.c11
3 files changed, 28 insertions, 16 deletions
diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c b/src/exchange/taler-exchange-httpd_common_kyc.c
index 05d1ffc8c..1adc808bc 100644
--- a/src/exchange/taler-exchange-httpd_common_kyc.c
+++ b/src/exchange/taler-exchange-httpd_common_kyc.c
@@ -322,7 +322,7 @@ kyc_aml_finished (
"Stored encrypted KYC process #%llu attributes: %d\n",
(unsigned long long) kat->process_row,
qs);
- if (qs <= 0)
+ if (qs < 0)
{
GNUNET_break (0);
if (NULL != kat->response)
diff --git a/src/exchangedb/exchange_do_insert_kyc_attributes.sql b/src/exchangedb/exchange_do_insert_kyc_attributes.sql
index e04775b83..5b086dd3e 100644
--- a/src/exchangedb/exchange_do_insert_kyc_attributes.sql
+++ b/src/exchangedb/exchange_do_insert_kyc_attributes.sql
@@ -68,20 +68,23 @@ RETURNING
INTO
my_trigger_outcome_serial;
-INSERT INTO kyc_attributes
- (h_payto
- ,collection_time
- ,expiration_time
- ,encrypted_attributes
- ,legitimization_serial
- ,trigger_outcome_serial
- ) VALUES
- (in_h_payto
- ,in_collection_time_ts
- ,in_expiration_time_ts
- ,in_enc_attributes
- ,in_process_row
- ,my_trigger_outcome_serial);
+IF in_process_row IS NOT NULL
+THEN
+ INSERT INTO kyc_attributes
+ (h_payto
+ ,collection_time
+ ,expiration_time
+ ,encrypted_attributes
+ ,legitimization_serial
+ ,trigger_outcome_serial
+ ) VALUES
+ (in_h_payto
+ ,in_collection_time_ts
+ ,in_expiration_time_ts
+ ,in_enc_attributes
+ ,in_process_row
+ ,my_trigger_outcome_serial);
+END IF;
UPDATE legitimization_processes
SET provider_user_id=in_provider_account_id
diff --git a/src/exchangedb/pg_insert_kyc_attributes.c b/src/exchangedb/pg_insert_kyc_attributes.c
index e7a0c12bd..897e2a4a3 100644
--- a/src/exchangedb/pg_insert_kyc_attributes.c
+++ b/src/exchangedb/pg_insert_kyc_attributes.c
@@ -26,6 +26,13 @@
#include "pg_helper.h"
+/*
+ * FIXME:
+ * This function does *so* much more than inserting KYC attributes.
+ * Sometimes it doesn't even insert KYC attributes at all.
+ * => Rename?
+ */
+
enum GNUNET_DB_QueryStatus
TEH_PG_insert_kyc_attributes (
void *cls,
@@ -56,7 +63,9 @@ TEH_PG_insert_kyc_attributes (
char *kyc_completed_notify_s
= GNUNET_PQ_get_event_notify_channel (&rep.header);
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint64 (&process_row),
+ (0 == process_row)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_uint64 (&process_row),
GNUNET_PQ_query_param_auto_from_type (h_payto),
GNUNET_PQ_query_param_uint32 (&birthday),
GNUNET_PQ_query_param_string (provider_name),