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

Generated by: LCOV version 2.0-1