LCOV - code coverage report
Current view: top level - exchangedb - trigger_kyc_rule_for_account.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.5 % 31 29
Test Date: 2026-04-14 15:39:31 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/trigger_kyc_rule_for_account.c
      18              :  * @brief Implementation of the trigger_kyc_rule_for_account function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "taler/taler_pq_lib.h"
      22              : #include "exchange-database/trigger_kyc_rule_for_account.h"
      23              : #include "helper.h"
      24              : 
      25              : 
      26              : enum GNUNET_DB_QueryStatus
      27           14 : TALER_EXCHANGEDB_trigger_kyc_rule_for_account (
      28              :   struct TALER_EXCHANGEDB_PostgresContext *pg,
      29              :   const struct TALER_FullPayto payto_uri,
      30              :   const struct TALER_NormalizedPaytoHashP *h_payto,
      31              :   const union TALER_AccountPublicKeyP *set_account_pub,
      32              :   const struct TALER_MerchantPublicKeyP *check_merchant_pub,
      33              :   const json_t *jmeasures,
      34              :   uint32_t display_priority,
      35              :   uint64_t *requirement_row,
      36              :   bool *bad_kyc_auth)
      37              : {
      38              :   struct GNUNET_TIME_Absolute now
      39           14 :     = GNUNET_TIME_absolute_get ();
      40           14 :   struct TALER_EXCHANGEDB_KycCompletedEventP rep = {
      41           14 :     .header.size = htons (sizeof (rep)),
      42           14 :     .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
      43              :     .h_payto = *h_payto
      44              :   };
      45              :   char *notify_str
      46           14 :     = GNUNET_PQ_get_event_notify_channel (&rep.header);
      47              :   struct TALER_FullPaytoHashP h_full_payto;
      48           14 :   struct GNUNET_PQ_QueryParam params[] = {
      49           14 :     GNUNET_PQ_query_param_auto_from_type (h_payto),
      50              :     NULL == set_account_pub
      51            7 :     ? GNUNET_PQ_query_param_null ()
      52           14 :     : GNUNET_PQ_query_param_auto_from_type (set_account_pub),
      53              :     NULL == check_merchant_pub
      54           13 :     ? GNUNET_PQ_query_param_null ()
      55           14 :     : GNUNET_PQ_query_param_auto_from_type (check_merchant_pub),
      56           14 :     NULL == payto_uri.full_payto
      57            0 :     ? GNUNET_PQ_query_param_null ()
      58           14 :     : GNUNET_PQ_query_param_string (payto_uri.full_payto),
      59           14 :     NULL == payto_uri.full_payto
      60            0 :     ? GNUNET_PQ_query_param_null ()
      61           14 :     : GNUNET_PQ_query_param_auto_from_type (&h_full_payto),
      62           14 :     GNUNET_PQ_query_param_absolute_time (&now),
      63           14 :     TALER_PQ_query_param_json (jmeasures),
      64           14 :     GNUNET_PQ_query_param_uint32 (&display_priority),
      65           14 :     GNUNET_PQ_query_param_string (notify_str),
      66              :     GNUNET_PQ_query_param_end
      67              :   };
      68           14 :   struct GNUNET_PQ_ResultSpec rs[] = {
      69           14 :     GNUNET_PQ_result_spec_uint64 (
      70              :       "legitimization_measure_serial_id",
      71              :       requirement_row),
      72           14 :     GNUNET_PQ_result_spec_bool (
      73              :       "bad_kyc_auth",
      74              :       bad_kyc_auth),
      75              :     GNUNET_PQ_result_spec_end
      76              :   };
      77              :   enum GNUNET_DB_QueryStatus qs;
      78              : 
      79           14 :   PREPARE (pg,
      80              :            "trigger_kyc_rule_for_account",
      81              :            "SELECT"
      82              :            "  out_legitimization_measure_serial_id"
      83              :            "   AS legitimization_measure_serial_id"
      84              :            " ,out_bad_kyc_auth"
      85              :            "   AS bad_kyc_auth"
      86              :            " FROM exchange_do_trigger_kyc_rule_for_account"
      87              :            "($1, $2, $3, $4, $5, $6, $7::TEXT::JSONB, $8, $9);");
      88           14 :   if (NULL != payto_uri.full_payto)
      89           14 :     TALER_full_payto_hash (payto_uri,
      90              :                            &h_full_payto);
      91           14 :   qs = GNUNET_PQ_eval_prepared_singleton_select (
      92              :     pg->conn,
      93              :     "trigger_kyc_rule_for_account",
      94              :     params,
      95              :     rs);
      96           14 :   GNUNET_free (notify_str);
      97           14 :   return qs;
      98              : }
        

Generated by: LCOV version 2.0-1