exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

insert_sanction_list_hit.c (3277B)


      1 /*
      2    This file is part of TALER
      3    Copyright (C) 2025 Taler Systems SA
      4 
      5    TALER is free software; you can redistribute it and/or modify it under the
      6    terms of the GNU General Public License as published by the Free Software
      7    Foundation; either version 3, or (at your option) any later version.
      8 
      9    TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11    A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12 
     13    You should have received a copy of the GNU General Public License along with
     14    TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15  */
     16 /**
     17  * @file exchangedb/insert_sanction_list_hit.c
     18  * @brief Implementation of the insert_sanction_list_hit function for Postgres
     19  * @author Christian Grothoff
     20  */
     21 #include "taler/taler_pq_lib.h"
     22 #include "exchange-database/insert_sanction_list_hit.h"
     23 #include "helper.h"
     24 
     25 
     26 enum GNUNET_DB_QueryStatus
     27 TALER_EXCHANGEDB_insert_sanction_list_hit (
     28   struct TALER_EXCHANGEDB_PostgresContext *pg,
     29   const struct TALER_NormalizedPaytoHashP *h_payto,
     30   bool to_investigate,
     31   const json_t *new_rules,
     32   const json_t *account_properties,
     33   unsigned int num_events,
     34   const char **events)
     35 {
     36   struct GNUNET_TIME_Timestamp never
     37     = GNUNET_TIME_UNIT_FOREVER_TS;
     38   struct GNUNET_TIME_Timestamp now
     39     = GNUNET_TIME_timestamp_get ();
     40   struct TALER_EXCHANGEDB_KycCompletedEventP rep = {
     41     .header.size = htons (sizeof (rep)),
     42     .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
     43     .h_payto = *h_payto
     44   };
     45   char *notify_s
     46     = GNUNET_PQ_get_event_notify_channel (&rep.header);
     47   struct GNUNET_PQ_QueryParam params[] = {
     48     GNUNET_PQ_query_param_auto_from_type (h_payto),
     49     GNUNET_PQ_query_param_timestamp (&now),
     50     GNUNET_PQ_query_param_timestamp (&never),
     51     NULL != account_properties
     52     ? TALER_PQ_query_param_json (account_properties)
     53     : GNUNET_PQ_query_param_null (),
     54     NULL != new_rules
     55     ? TALER_PQ_query_param_json (new_rules)
     56     : GNUNET_PQ_query_param_null (),
     57     GNUNET_PQ_query_param_bool (to_investigate),
     58     GNUNET_PQ_query_param_string (notify_s),
     59     GNUNET_PQ_query_param_array_ptrs_string (num_events,
     60                                              events,
     61                                              pg->conn),
     62     GNUNET_PQ_query_param_end
     63   };
     64   uint64_t outcome_serial_id;
     65   struct GNUNET_PQ_ResultSpec rs[] = {
     66     GNUNET_PQ_result_spec_uint64 ("outcome_serial_id",
     67                                   &outcome_serial_id),
     68     GNUNET_PQ_result_spec_end
     69   };
     70   enum GNUNET_DB_QueryStatus qs;
     71 
     72   PREPARE (pg,
     73            "do_insert_sanction_list_hit",
     74            "SELECT"
     75            " out_outcome_serial_id AS outcome_serial_id"
     76            " FROM exchange_do_insert_sanction_list_hit"
     77            "($1,$2,$3,$4::TEXT::JSONB,$5::TEXT::JSONB,$6,$7,$8);");
     78   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
     79               "Inserting LEGI OUTCOME from sanction list hit\n");
     80   qs = GNUNET_PQ_eval_prepared_singleton_select (
     81     pg->conn,
     82     "do_insert_sanction_list_hit",
     83     params,
     84     rs);
     85   (void) outcome_serial_id;
     86   GNUNET_PQ_cleanup_query_params_closures (params);
     87   GNUNET_free (notify_s);
     88   GNUNET_PQ_event_do_poll (pg->conn);
     89   return qs;
     90 }