gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[exchange] branch master updated (3a14fc370 -> 33f7da0f5)


From: gnunet
Subject: [exchange] branch master updated (3a14fc370 -> 33f7da0f5)
Date: Tue, 21 Jan 2025 15:50:13 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository exchange.

 discard 3a14fc370 implement new_measures handling for AMP results

This update removed existing revisions from the reference, leaving the
reference pointing at a previous point in the repository history.

 * -- * -- N   refs/heads/master (33f7da0f5)
            \
             O -- O -- O   (3a14fc370)

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 src/exchange/taler-exchange-httpd_common_kyc.c     |  66 ++++----------
 src/exchangedb/Makefile.am                         |   1 +
 src/exchangedb/exchange_do_insert_aml_decision.sql |  66 ++++++--------
 .../exchange_do_insert_kyc_measure_result.sql      | 101 +++++++++++++++++++++
 src/exchangedb/exchangedb_aml.c                    |  64 +++----------
 src/exchangedb/pg_insert_aml_decision.c            |  19 +---
 ...attributes.c => pg_insert_kyc_measure_result.c} |  61 ++++++-------
 ...n_list_hit.h => pg_insert_kyc_measure_result.h} |  34 +++----
 src/exchangedb/plugin_exchangedb_postgres.c        |   3 +
 src/exchangedb/procedures.sql.in                   |   1 +
 src/include/taler_exchangedb_plugin.h              |  29 ++++++
 src/include/taler_kyclogic_lib.h                   |   5 -
 src/kyclogic/kyclogic_api.c                        |   5 -
 13 files changed, 246 insertions(+), 209 deletions(-)
 create mode 100644 src/exchangedb/exchange_do_insert_kyc_measure_result.sql
 copy src/exchangedb/{pg_persist_kyc_attributes.c => 
pg_insert_kyc_measure_result.c} (61%)
 copy src/exchangedb/{pg_insert_sanction_list_hit.h => 
pg_insert_kyc_measure_result.h} (65%)

diff --git a/src/exchange/taler-exchange-httpd_common_kyc.c 
b/src/exchange/taler-exchange-httpd_common_kyc.c
index 4ef825135..a88113a17 100644
--- a/src/exchange/taler-exchange-httpd_common_kyc.c
+++ b/src/exchange/taler-exchange-httpd_common_kyc.c
@@ -611,8 +611,6 @@ handle_aml_fallback_result (
   struct TEH_KycAmlFallback *fb = cls;
   enum GNUNET_DB_QueryStatus qs;
   struct GNUNET_AsyncScopeSave old_scope;
-  json_t *jmeasures = NULL;
-  struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL;
 
   fb->aprh = NULL;
   GNUNET_async_scope_enter (&fb->scope,
@@ -633,72 +631,46 @@ handle_aml_fallback_result (
       fb->cb (fb->cb_cls,
               false,
               0);
-      goto cleanup;
+      TEH_kyc_fallback_cancel (fb);
+      GNUNET_async_scope_restore (&old_scope);
+      return;
     }
     /* Fallback not allowed on fallback */
     GNUNET_break (0);
     fb->cb (fb->cb_cls,
             false,
             0);
-    goto cleanup;
-  }
-
-  if (NULL != apr->details.success.new_measures)
-  {
-    lrs = TALER_KYCLOGIC_rules_parse (apr->details.success.new_rules);
-    GNUNET_assert (NULL != lrs);
-    jmeasures = TALER_KYCLOGIC_get_jmeasures (
-      lrs,
-      apr->details.success.new_measures);
-    GNUNET_assert (NULL != jmeasures);
-  }
-
-  {
-    struct TALER_FullPayto null_payto_uri = { 0 };
-    bool invalid_officer;
-    bool unknown_account;
-    struct GNUNET_TIME_Timestamp last_date;
-    uint64_t legitimization_measure_serial_id;
-
-    qs = TEH_plugin->insert_aml_decision (
-      TEH_plugin->cls,
-      null_payto_uri,
-      &fb->account_id,
-      GNUNET_TIME_timestamp_get (),
-      apr->details.success.expiration_time,
-      apr->details.success.account_properties,
-      apr->details.success.new_rules,
-      apr->details.success.to_investigate,
-      apr->details.success.new_measures,
-      jmeasures,
-      NULL, /* justification */
-      NULL, /* decider_pub */
-      NULL, /* decider_sig */
-      apr->details.success.num_events,
-      apr->details.success.events,
-      &invalid_officer,
-      &unknown_account,
-      &last_date,
-      &legitimization_measure_serial_id);
+    TEH_kyc_fallback_cancel (fb);
+    GNUNET_async_scope_restore (&old_scope);
+    return;
   }
 
+  qs = TEH_plugin->insert_kyc_measure_result (
+    TEH_plugin->cls,
+    fb->orig_requirement_row,
+    &fb->account_id,
+    apr->details.success.expiration_time,
+    apr->details.success.account_properties,
+    apr->details.success.new_rules,
+    apr->details.success.to_investigate,
+    apr->details.success.num_events,
+    apr->details.success.events);
   if (qs < 0)
   {
     GNUNET_break (0);
     fb->cb (fb->cb_cls,
             false,
             0);
-    goto cleanup;
+    GNUNET_async_scope_restore (&old_scope);
+    TEH_kyc_fallback_cancel (fb);
+    return;
   }
   /* Finally, return result to main handler */
   fb->cb (fb->cb_cls,
           true,
           0);
-cleanup:
   TEH_kyc_fallback_cancel (fb);
   GNUNET_async_scope_restore (&old_scope);
-  TALER_KYCLOGIC_rules_free (lrs);
-  json_decref (jmeasures);
 }
 
 
diff --git a/src/exchangedb/Makefile.am b/src/exchangedb/Makefile.am
index 7d3e262c1..5f3c5bf3d 100644
--- a/src/exchangedb/Makefile.am
+++ b/src/exchangedb/Makefile.am
@@ -210,6 +210,7 @@ libtaler_plugin_exchangedb_postgres_la_SOURCES = \
   pg_insert_drain_profit.h pg_insert_drain_profit.c \
   pg_insert_global_fee.h pg_insert_global_fee.c \
   pg_insert_kyc_failure.h pg_insert_kyc_failure.c \
+  pg_insert_kyc_measure_result.h pg_insert_kyc_measure_result.c \
   pg_insert_kyc_requirement_process.h pg_insert_kyc_requirement_process.c \
   pg_insert_partner.h pg_insert_partner.c \
   pg_insert_purse_request.h pg_insert_purse_request.c \
diff --git a/src/exchangedb/exchange_do_insert_aml_decision.sql 
b/src/exchangedb/exchange_do_insert_aml_decision.sql
index d8d95d950..71f1cf382 100644
--- a/src/exchangedb/exchange_do_insert_aml_decision.sql
+++ b/src/exchangedb/exchange_do_insert_aml_decision.sql
@@ -26,9 +26,9 @@ CREATE FUNCTION exchange_do_insert_aml_decision(
   IN in_to_investigate BOOLEAN,
   IN in_new_measure_name TEXT, -- can be NULL
   IN in_jmeasures TEXT, -- can be NULL
-  IN in_justification TEXT, -- can be NULL
-  IN in_decider_pub BYTEA, -- can be NULL
-  IN in_decider_sig BYTEA, -- can be NULL
+  IN in_justification TEXT,
+  IN in_decider_pub BYTEA,
+  IN in_decider_sig BYTEA,
   IN in_notify_s TEXT,
   IN ina_events TEXT[],
   OUT out_invalid_officer BOOLEAN,
@@ -47,26 +47,18 @@ BEGIN
 out_account_unknown=FALSE;
 out_legitimization_measure_serial_id=0;
 
-IF in_decider_pub IS NOT NULL
+-- Check officer is eligible to make decisions.
+PERFORM
+  FROM aml_staff
+  WHERE decider_pub=in_decider_pub
+    AND is_active
+    AND NOT read_only;
+IF NOT FOUND
 THEN
-  IF in_justification IS NULL OR in_decider_sig IS NULL
-  THEN
-    RAISE EXCEPTION 'Got in_decider_sig without justification or signature.';
-  END IF;
-  -- Check officer is eligible to make decisions.
-  PERFORM
-    FROM aml_staff
-    WHERE decider_pub=in_decider_pub
-      AND is_active
-      AND NOT read_only;
-  IF NOT FOUND
-  THEN
-    out_invalid_officer=TRUE;
-    out_last_date=0;
-    RETURN;
-  END IF;
+  out_invalid_officer=TRUE;
+  out_last_date=0;
+  RETURN;
 END IF;
-
 out_invalid_officer=FALSE;
 
 -- Check no more recent decision exists.
@@ -79,9 +71,9 @@ SELECT decision_time
 
 IF FOUND
 THEN
-  IF in_decider_pub IS NOT NULL AND out_last_date > in_decision_time
+  IF out_last_date > in_decision_time
   THEN
-    -- Refuse to insert older decision for officer decisions.
+    -- Refuse to insert older decision.
     RETURN;
   END IF;
   UPDATE legitimization_outcomes
@@ -188,22 +180,20 @@ INSERT INTO legitimization_outcomes
   INTO
     my_outcome_serial_id;
 
-IF in_decider_pub IS NOT NULL
-THEN
-  INSERT INTO aml_history
-    (h_payto
-    ,outcome_serial_id
-    ,justification
-    ,decider_pub
-    ,decider_sig
-    ) VALUES
-    (in_h_normalized_payto
-    ,my_outcome_serial_id
-    ,in_justification
-    ,in_decider_pub
-    ,in_decider_sig
+
+INSERT INTO aml_history
+  (h_payto
+  ,outcome_serial_id
+  ,justification
+  ,decider_pub
+  ,decider_sig
+  ) VALUES
+  (in_h_normalized_payto
+  ,my_outcome_serial_id
+  ,in_justification
+  ,in_decider_pub
+  ,in_decider_sig
   );
-END IF;
 
 -- Trigger events
 FOR i IN 1..COALESCE(array_length(ina_events,1),0)
diff --git a/src/exchangedb/exchange_do_insert_kyc_measure_result.sql 
b/src/exchangedb/exchange_do_insert_kyc_measure_result.sql
new file mode 100644
index 000000000..f3c41239a
--- /dev/null
+++ b/src/exchangedb/exchange_do_insert_kyc_measure_result.sql
@@ -0,0 +1,101 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2023, 2024 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
+-- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+--
+
+DROP FUNCTION IF EXISTS exchange_do_insert_kyc_measure_result;
+CREATE FUNCTION exchange_do_insert_kyc_measure_result(
+  IN in_process_row INT8,
+  IN in_h_payto BYTEA,
+  IN in_decision_time INT8,
+  IN in_expiration_time_ts INT8,
+  IN in_account_properties TEXT,
+  IN in_new_rules TEXT,
+  IN ina_events TEXT[],
+  IN in_to_investigate BOOLEAN,
+  IN in_kyc_completed_notify_s TEXT,
+  OUT out_ok BOOLEAN)
+LANGUAGE plpgsql
+AS $$
+DECLARE
+  my_trigger_outcome_serial INT8;
+  my_lmsi INT8;
+  my_i INT4;
+  ini_event TEXT;
+BEGIN
+
+-- Disactivate all previous outcomes.
+UPDATE legitimization_outcomes
+   SET is_active=FALSE
+ WHERE h_payto=in_h_payto;
+
+-- Insert new rules
+INSERT INTO legitimization_outcomes
+  (h_payto
+  ,decision_time
+  ,expiration_time
+  ,jproperties
+  ,to_investigate
+  ,jnew_rules)
+VALUES
+  (in_h_payto
+  ,in_decision_time
+  ,in_expiration_time_ts
+  ,in_account_properties
+  ,in_to_investigate
+  ,in_new_rules)
+RETURNING
+  outcome_serial_id
+INTO
+  my_trigger_outcome_serial;
+
+-- Mark measure as complete
+UPDATE legitimization_measures
+   SET is_finished=TRUE
+ WHERE legitimization_measure_serial_id=
+ (SELECT legitimization_measure_serial_id
+    FROM legitimization_processes
+   WHERE h_payto=in_h_payto
+     AND legitimization_process_serial_id=in_process_row);
+out_ok = FOUND;
+
+-- Trigger events
+FOR i IN 1..COALESCE(array_length(ina_events,1),0)
+LOOP
+  ini_event = ina_events[i];
+  INSERT INTO kyc_events
+    (event_timestamp
+    ,event_type)
+    VALUES
+    (in_decision_time
+    ,ini_event);
+END LOOP;
+
+-- Notify about KYC update
+EXECUTE FORMAT (
+ 'NOTIFY %s'
+ ,in_kyc_completed_notify_s);
+
+INSERT INTO kyc_alerts
+ (h_payto
+ ,trigger_type)
+ VALUES
+ (in_h_payto,1)
+ ON CONFLICT DO NOTHING;
+
+END $$;
+
+
+COMMENT ON FUNCTION exchange_do_insert_kyc_measure_result(INT8, BYTEA, INT8, 
INT8, TEXT, TEXT, TEXT[], BOOL, TEXT)
+  IS 'Inserts AML program outcome and updates the status of the legitimization 
process and the AML status for the account';
diff --git a/src/exchangedb/exchangedb_aml.c b/src/exchangedb/exchangedb_aml.c
index 0b2936bc4..0444e2217 100644
--- a/src/exchangedb/exchangedb_aml.c
+++ b/src/exchangedb/exchangedb_aml.c
@@ -40,18 +40,6 @@ TALER_EXCHANGEDB_persist_aml_program_result (
   const struct TALER_KYCLOGIC_AmlProgramResult *apr)
 {
   enum GNUNET_DB_QueryStatus qs;
-  json_t *jmeasures = NULL;
-  struct TALER_KYCLOGIC_LegitimizationRuleSet *lrs = NULL;
-
-  if (NULL != apr->details.success.new_measures)
-  {
-    lrs = TALER_KYCLOGIC_rules_parse (apr->details.success.new_rules);
-    GNUNET_assert (NULL != lrs);
-    jmeasures = TALER_KYCLOGIC_get_jmeasures (
-      lrs,
-      apr->details.success.new_measures);
-    GNUNET_assert (NULL != jmeasures);
-  }
 
   qs = plugin->clear_aml_lock (
     plugin->cls,
@@ -66,45 +54,23 @@ TALER_EXCHANGEDB_persist_aml_program_result (
       apr->details.failure.error_message,
       apr->details.failure.ec);
     GNUNET_break (qs > 0);
-    goto cleanup;
+    return qs;
   case TALER_KYCLOGIC_AMLR_SUCCESS:
-    {
-      struct TALER_FullPayto null_payto_uri = { 0 };
-      bool invalid_officer;
-      bool unknown_account;
-      struct GNUNET_TIME_Timestamp last_date;
-      uint64_t legitimization_measure_serial_id;
-
-      qs = plugin->insert_aml_decision (
-        plugin->cls,
-        null_payto_uri,
-        account_id,
-        GNUNET_TIME_timestamp_get (),
-        apr->details.success.expiration_time,
-        apr->details.success.account_properties,
-        apr->details.success.new_rules,
-        apr->details.success.to_investigate,
-        apr->details.success.new_measures,
-        jmeasures,
-        NULL, /* justification */
-        NULL, /* decider_pub */
-        NULL, /* decider_sig */
-        apr->details.success.num_events,
-        apr->details.success.events,
-        &invalid_officer,
-        &unknown_account,
-        &last_date,
-        &legitimization_measure_serial_id);
-      GNUNET_break (qs > 0);
-      goto cleanup;
-    }
+    qs = plugin->insert_kyc_measure_result (
+      plugin->cls,
+      process_row,
+      account_id,
+      apr->details.success.expiration_time,
+      apr->details.success.account_properties,
+      apr->details.success.new_rules,
+      apr->details.success.to_investigate,
+      apr->details.success.num_events,
+      apr->details.success.events);
+    GNUNET_break (qs > 0);
+    return qs;
   }
-  GNUNET_break (0);
-  qs = GNUNET_DB_STATUS_HARD_ERROR;
-cleanup:
-  TALER_KYCLOGIC_rules_free (lrs);
-  json_decref (jmeasures);
-  return qs;
+  GNUNET_assert (0);
+  return GNUNET_DB_STATUS_HARD_ERROR;
 }
 
 
diff --git a/src/exchangedb/pg_insert_aml_decision.c 
b/src/exchangedb/pg_insert_aml_decision.c
index dcae300bc..de314ef89 100644
--- a/src/exchangedb/pg_insert_aml_decision.c
+++ b/src/exchangedb/pg_insert_aml_decision.c
@@ -79,15 +79,9 @@ TEH_PG_insert_aml_decision (
     NULL != jmeasures
       ? TALER_PQ_query_param_json (jmeasures)
       : GNUNET_PQ_query_param_null (),
-    NULL != justification
-      ? GNUNET_PQ_query_param_string (justification)
-      : GNUNET_PQ_query_param_null (),
-    NULL != decider_pub
-      ? GNUNET_PQ_query_param_auto_from_type (decider_pub)
-      : GNUNET_PQ_query_param_null (),
-    NULL != decider_sig
-      ? GNUNET_PQ_query_param_auto_from_type (decider_sig)
-      : GNUNET_PQ_query_param_null (),
+    GNUNET_PQ_query_param_string (justification),
+    GNUNET_PQ_query_param_auto_from_type (decider_pub),
+    GNUNET_PQ_query_param_auto_from_type (decider_sig),
     GNUNET_PQ_query_param_string (notify_s),
     GNUNET_PQ_query_param_array_ptrs_string (num_events,
                                              events,
@@ -107,13 +101,6 @@ TEH_PG_insert_aml_decision (
   };
   enum GNUNET_DB_QueryStatus qs;
 
-  GNUNET_assert ( ( (NULL == decider_pub) &&
-                    (NULL == decider_sig) &&
-                    (NULL == justification) ) ||
-                  ( (NULL != decider_pub) &&
-                    (NULL != decider_sig) &&
-                    (NULL != justification) ) );
-
   if (NULL != payto_uri.full_payto)
     TALER_full_payto_hash (payto_uri,
                            &h_full_payto);
diff --git a/src/exchangedb/pg_persist_kyc_attributes.c 
b/src/exchangedb/pg_insert_kyc_measure_result.c
similarity index 61%
copy from src/exchangedb/pg_persist_kyc_attributes.c
copy to src/exchangedb/pg_insert_kyc_measure_result.c
index 28ccdef07..c8698c7b4 100644
--- a/src/exchangedb/pg_persist_kyc_attributes.c
+++ b/src/exchangedb/pg_insert_kyc_measure_result.c
@@ -1,6 +1,6 @@
 /*
    This file is part of TALER
-   Copyright (C) 2024 Taler Systems SA
+   Copyright (C) 2022, 2023, 2024 Taler Systems SA
 
    TALER is free software; you can redistribute it and/or modify it under the
    terms of the GNU General Public License as published by the Free Software
@@ -14,41 +14,38 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_persist_kyc_attributes.c
- * @brief Implementation of the persist_kyc_attributes function for Postgres
+ * @file exchangedb/pg_insert_kyc_measure_result.c
+ * @brief Implementation of the insert_kyc_measure_result function for Postgres
  * @author Christian Grothoff
  */
 #include "platform.h"
 #include "taler_error_codes.h"
 #include "taler_dbevents.h"
 #include "taler_pq_lib.h"
-#include "pg_persist_kyc_attributes.h"
+#include "pg_insert_kyc_measure_result.h"
 #include "pg_helper.h"
 
 
 enum GNUNET_DB_QueryStatus
-TEH_PG_persist_kyc_attributes (
+TEH_PG_insert_kyc_measure_result (
   void *cls,
   uint64_t process_row,
   const struct TALER_NormalizedPaytoHashP *h_payto,
-  const char *provider_name,
-  const char *provider_account_id,
-  const char *provider_legitimization_id,
-  uint32_t birthday,
-  struct GNUNET_TIME_Absolute expiration_time,
-  size_t enc_attributes_size,
-  const void *enc_attributes)
+  struct GNUNET_TIME_Timestamp expiration_time,
+  const json_t *account_properties,
+  const json_t *new_rules,
+  bool to_investigate,
+  unsigned int num_events,
+  const char **events)
 {
   struct PostgresClosure *pg = cls;
-  struct GNUNET_TIME_Timestamp collection_time
-    = GNUNET_TIME_timestamp_get ();
-  struct GNUNET_TIME_Timestamp expiration
-    = GNUNET_TIME_absolute_to_timestamp (expiration_time);
   struct TALER_KycCompletedEventP rep = {
     .header.size = htons (sizeof (rep)),
     .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
     .h_payto = *h_payto
   };
+  struct GNUNET_TIME_Timestamp now
+    = GNUNET_TIME_timestamp_get ();
   char *kyc_completed_notify_s
     = GNUNET_PQ_get_event_notify_channel (&rep.header);
   struct GNUNET_PQ_QueryParam params[] = {
@@ -56,21 +53,18 @@ TEH_PG_persist_kyc_attributes (
     ? 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),
-    (NULL == provider_account_id)
-    ? GNUNET_PQ_query_param_null ()
-    : GNUNET_PQ_query_param_string (provider_account_id),
-    (NULL == provider_legitimization_id)
+    GNUNET_PQ_query_param_timestamp (&now),
+    GNUNET_PQ_query_param_timestamp (&expiration_time),
+    NULL == account_properties
     ? GNUNET_PQ_query_param_null ()
-    : GNUNET_PQ_query_param_string (provider_legitimization_id),
-    GNUNET_PQ_query_param_timestamp (&collection_time),
-    GNUNET_PQ_query_param_absolute_time (&expiration_time),
-    GNUNET_PQ_query_param_timestamp (&expiration),
-    (NULL == enc_attributes)
+    : TALER_PQ_query_param_json (account_properties),
+    NULL == new_rules
     ? GNUNET_PQ_query_param_null ()
-    : GNUNET_PQ_query_param_fixed_size (enc_attributes,
-                                        enc_attributes_size),
+    : TALER_PQ_query_param_json (new_rules),
+    GNUNET_PQ_query_param_array_ptrs_string (num_events,
+                                             events,
+                                             pg->conn),
+    GNUNET_PQ_query_param_bool (to_investigate),
     GNUNET_PQ_query_param_string (kyc_completed_notify_s),
     GNUNET_PQ_query_param_end
   };
@@ -87,17 +81,18 @@ TEH_PG_persist_kyc_attributes (
               kyc_completed_notify_s);
   GNUNET_break (NULL != h_payto);
   PREPARE (pg,
-           "persist_kyc_attributes",
+           "insert_kyc_measure_result",
            "SELECT "
            " out_ok"
-           " FROM exchange_do_persist_kyc_attributes "
-           "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
+           " FROM exchange_do_insert_kyc_measure_result "
+           "($1, $2, $3, $4, $5, $6, $7, $8, $9);");
   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
-                                                 "persist_kyc_attributes",
+                                                 "insert_kyc_measure_result",
                                                  params,
                                                  rs);
   GNUNET_PQ_cleanup_query_params_closures (params);
   GNUNET_free (kyc_completed_notify_s);
   GNUNET_PQ_event_do_poll (pg->conn);
+  GNUNET_break (ok);
   return qs;
 }
diff --git a/src/exchangedb/pg_insert_sanction_list_hit.h 
b/src/exchangedb/pg_insert_kyc_measure_result.h
similarity index 65%
copy from src/exchangedb/pg_insert_sanction_list_hit.h
copy to src/exchangedb/pg_insert_kyc_measure_result.h
index 5149034fd..44a586aa5 100644
--- a/src/exchangedb/pg_insert_sanction_list_hit.h
+++ b/src/exchangedb/pg_insert_kyc_measure_result.h
@@ -1,6 +1,6 @@
 /*
    This file is part of TALER
-   Copyright (C) 2025 Taler Systems SA
+   Copyright (C) 2022, 2023 Taler Systems SA
 
    TALER is free software; you can redistribute it and/or modify it under the
    terms of the GNU General Public License as published by the Free Software
@@ -14,12 +14,12 @@
    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 /**
- * @file exchangedb/pg_insert_sanction_list_hit.h
- * @brief implementation of the insert_sanction_list_hit function for Postgres
+ * @file exchangedb/pg_insert_kyc_measure_result.h
+ * @brief implementation of the insert_kyc_measure_result function for Postgres
  * @author Christian Grothoff
  */
-#ifndef PG_INSERT_SANCTION_LIST_HIT_H
-#define PG_INSERT_SANCTION_LIST_HIT_H
+#ifndef PG_INSERT_KYC_ATTRIBUTES_H
+#define PG_INSERT_KYC_ATTRIBUTES_H
 
 #include "taler_util.h"
 #include "taler_json_lib.h"
@@ -27,29 +27,31 @@
 
 
 /**
- * Update sanction list hit status of the given account.
+ * Update KYC process status and AML status for the given account based on AML
+ * program result.
  *
  * @param cls closure
- * @param h_payto account for which the hit is to be stored
- * @param to_investigate true to flag account for investigation,
- *        false to **preserve** existing status
- * @param new_rules new KYC rules to apply to the account, NULL to preserve
- *        existing rules
+ * @param process_row KYC process row to update
+ * @param h_payto account for which the attribute data is stored
+ * @param expiration_time when do the @a new_rules expire
  * @param account_properties new account properties
- * @param expiration_time when does the sanction list entry expire?
+ * @param new_rules new KYC rules to apply to the account
+ * @param to_investigate true to flag account for investigation
  * @param num_events length of the @a events array
  * @param events array of KYC events to trigger
  * @return database transaction status
  */
 enum GNUNET_DB_QueryStatus
-TEH_PG_insert_sanction_list_hit (
+TEH_PG_insert_kyc_measure_result (
   void *cls,
+  uint64_t process_row,
   const struct TALER_NormalizedPaytoHashP *h_payto,
-  bool to_investigate,
-  const json_t *new_rules,
-  const json_t *account_properties,
   struct GNUNET_TIME_Timestamp expiration_time,
+  const json_t *account_properties,
+  const json_t *new_rules,
+  bool to_investigate,
   unsigned int num_events,
   const char **events);
 
+
 #endif
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index f669d1c8b..132bf4c6a 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -114,6 +114,7 @@
 #include "pg_insert_drain_profit.h"
 #include "pg_insert_global_fee.h"
 #include "pg_insert_kyc_failure.h"
+#include "pg_insert_kyc_measure_result.h"
 #include "pg_insert_kyc_requirement_process.h"
 #include "pg_insert_partner.h"
 #include "pg_insert_purse_request.h"
@@ -750,6 +751,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
     = &TEH_PG_set_purse_balance;
   plugin->get_pending_kyc_requirement_process
     = &TEH_PG_get_pending_kyc_requirement_process;
+  plugin->insert_kyc_measure_result
+    = &TEH_PG_insert_kyc_measure_result;
   plugin->select_kyc_attributes
     = &TEH_PG_select_kyc_attributes;
   plugin->insert_aml_officer
diff --git a/src/exchangedb/procedures.sql.in b/src/exchangedb/procedures.sql.in
index ad81eeb81..f2936b5a7 100644
--- a/src/exchangedb/procedures.sql.in
+++ b/src/exchangedb/procedures.sql.in
@@ -46,6 +46,7 @@ SET search_path TO exchange;
 #include "exchange_do_insert_aml_decision.sql"
 #include "exchange_do_insert_successor_measure.sql"
 #include "exchange_do_insert_aml_officer.sql"
+#include "exchange_do_insert_kyc_measure_result.sql"
 #include "exchange_do_reserves_in_insert.sql"
 #include "exchange_do_batch_reserves_update.sql"
 #include "exchange_do_get_link_data.sql"
diff --git a/src/include/taler_exchangedb_plugin.h 
b/src/include/taler_exchangedb_plugin.h
index ffe6a0c94..db6801732 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -7351,6 +7351,35 @@ struct TALER_EXCHANGEDB_Plugin
     void *kac_cls);
 
 
+  /**
+   * Update KYC process status and
+   * AML status for the given account based on
+   * AML program outcome.
+   *
+   * @param cls closure
+   * @param process_row KYC process row to update
+   * @param h_payto account for which the attribute data is stored
+   * @param expiration_time when do the @a new_rules expire
+   * @param account_properties new account properties
+   * @param new_rules new KYC rules to apply to the account
+   * @param to_investigate true to flag account for investigation
+   * @param num_events length of the @a events array
+   * @param events array of KYC events to trigger
+   * @return database transaction status
+   */
+  enum GNUNET_DB_QueryStatus
+    (*insert_kyc_measure_result)(
+    void *cls,
+    uint64_t process_row,
+    const struct TALER_NormalizedPaytoHashP *h_payto,
+    struct GNUNET_TIME_Timestamp expiration_time,
+    const json_t *account_properties,
+    const json_t *new_rules,
+    bool to_investigate,
+    unsigned int num_events,
+    const char **events);
+
+
   /**
    * Update sanction list hit status of the given account.
    *
diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h
index 6887ec5cd..35016e970 100644
--- a/src/include/taler_kyclogic_lib.h
+++ b/src/include/taler_kyclogic_lib.h
@@ -919,11 +919,6 @@ struct TALER_KYCLOGIC_AmlProgramResult
        */
       const json_t *new_rules;
 
-      /**
-       * New measures to trigger immediately.
-       */
-      const char *new_measures;
-
       /**
        * When do the new rules expire.
        */
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index f640dcc40..d8807d285 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -3990,11 +3990,6 @@ handle_aml_output (
       GNUNET_JSON_spec_object_const (
         "new_rules",
         &apr->details.success.new_rules),
-      GNUNET_JSON_spec_mark_optional (
-        GNUNET_JSON_spec_string (
-          "new_measures",
-          &apr->details.success.new_measures),
-        NULL),
       GNUNET_JSON_spec_end ()
     };
     const char *err;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]