LCOV - code coverage report
Current view: top level - exchangedb - pg_persist_kyc_attributes.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.9 % 37 34
Test Date: 2025-12-28 14:06:02 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :    This file is part of TALER
       3              :    Copyright (C) 2024 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/pg_persist_kyc_attributes.c
      18              :  * @brief Implementation of the persist_kyc_attributes function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/platform.h"
      22              : #include "taler/taler_error_codes.h"
      23              : #include "taler/taler_dbevents.h"
      24              : #include "taler/taler_pq_lib.h"
      25              : #include "pg_persist_kyc_attributes.h"
      26              : #include "pg_helper.h"
      27              : 
      28              : 
      29              : enum GNUNET_DB_QueryStatus
      30           10 : TEH_PG_persist_kyc_attributes (
      31              :   void *cls,
      32              :   uint64_t process_row,
      33              :   const struct TALER_NormalizedPaytoHashP *h_payto,
      34              :   const char *provider_name,
      35              :   const char *provider_account_id,
      36              :   const char *provider_legitimization_id,
      37              :   uint32_t birthday,
      38              :   struct GNUNET_TIME_Absolute expiration_time,
      39              :   const char *form_name,
      40              :   size_t enc_attributes_size,
      41              :   const void *enc_attributes)
      42              : {
      43           10 :   struct PostgresClosure *pg = cls;
      44              :   struct GNUNET_TIME_Timestamp collection_time
      45           10 :     = GNUNET_TIME_timestamp_get ();
      46              :   struct GNUNET_TIME_Timestamp expiration
      47           10 :     = GNUNET_TIME_absolute_to_timestamp (expiration_time);
      48           10 :   struct TALER_KycCompletedEventP rep = {
      49           10 :     .header.size = htons (sizeof (rep)),
      50           10 :     .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
      51              :     .h_payto = *h_payto
      52              :   };
      53              :   char *kyc_completed_notify_s
      54           10 :     = GNUNET_PQ_get_event_notify_channel (&rep.header);
      55           10 :   struct GNUNET_PQ_QueryParam params[] = {
      56           10 :     (0 == process_row)
      57            0 :     ? GNUNET_PQ_query_param_null ()
      58           10 :     : GNUNET_PQ_query_param_uint64 (&process_row),
      59           10 :     GNUNET_PQ_query_param_auto_from_type (h_payto),
      60           10 :     GNUNET_PQ_query_param_uint32 (&birthday),
      61           10 :     GNUNET_PQ_query_param_string (provider_name),
      62              :     (NULL == provider_account_id)
      63            1 :     ? GNUNET_PQ_query_param_null ()
      64           10 :     : GNUNET_PQ_query_param_string (provider_account_id),
      65              :     (NULL == provider_legitimization_id)
      66            1 :     ? GNUNET_PQ_query_param_null ()
      67           10 :     : GNUNET_PQ_query_param_string (provider_legitimization_id),
      68           10 :     GNUNET_PQ_query_param_timestamp (&collection_time),
      69           10 :     GNUNET_PQ_query_param_absolute_time (&expiration_time),
      70           10 :     GNUNET_PQ_query_param_timestamp (&expiration),
      71              :     (NULL == enc_attributes)
      72            0 :     ? GNUNET_PQ_query_param_null ()
      73           10 :     : GNUNET_PQ_query_param_fixed_size (enc_attributes,
      74              :                                         enc_attributes_size),
      75           10 :     GNUNET_PQ_query_param_string (kyc_completed_notify_s),
      76              :     (NULL == form_name)
      77            0 :     ? GNUNET_PQ_query_param_null ()
      78           10 :     : GNUNET_PQ_query_param_string (form_name),
      79              :     GNUNET_PQ_query_param_end
      80              :   };
      81              :   bool ok;
      82           10 :   struct GNUNET_PQ_ResultSpec rs[] = {
      83           10 :     GNUNET_PQ_result_spec_bool ("out_ok",
      84              :                                 &ok),
      85              :     GNUNET_PQ_result_spec_end
      86              :   };
      87              :   enum GNUNET_DB_QueryStatus qs;
      88              : 
      89           10 :   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
      90              :               "Inserting KYC attributes, wake up on %s\n",
      91              :               kyc_completed_notify_s);
      92           10 :   GNUNET_break (NULL != h_payto);
      93           10 :   PREPARE (pg,
      94              :            "persist_kyc_attributes",
      95              :            "SELECT "
      96              :            " out_ok"
      97              :            " FROM exchange_do_persist_kyc_attributes "
      98              :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);");
      99           10 :   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
     100              :                                                  "persist_kyc_attributes",
     101              :                                                  params,
     102              :                                                  rs);
     103           10 :   GNUNET_PQ_cleanup_query_params_closures (params);
     104           10 :   GNUNET_free (kyc_completed_notify_s);
     105           10 :   GNUNET_PQ_event_do_poll (pg->conn);
     106           10 :   return qs;
     107              : }
        

Generated by: LCOV version 2.0-1