LCOV - code coverage report
Current view: top level - backenddb - insert_kyc_failure.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 87.9 % 33 29
Test Date: 2026-09-04 23:42:01 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 src/backenddb/insert_kyc_failure.c
      18              :  * @brief Implementation of the insert_kyc_failure function for Postgres
      19              :  * @author Christian Grothoff
      20              :  */
      21              : #include "platform.h"
      22              : #include <taler/taler_dbevents.h>
      23              : #include <taler/taler_pq_lib.h>
      24              : #include "merchant-database/insert_kyc_failure.h"
      25              : #include "helper.h"
      26              : 
      27              : 
      28              : enum GNUNET_DB_QueryStatus
      29            2 : TALER_MERCHANTDB_insert_kyc_failure (
      30              :   struct TALER_MERCHANTDB_PostgresContext *pg,
      31              :   const char *merchant_id,
      32              :   const struct TALER_MerchantWireHashP *h_wire,
      33              :   const char *exchange_url,
      34              :   struct GNUNET_TIME_Timestamp timestamp,
      35              :   unsigned int exchange_http_status,
      36              :   bool kyc_ok)
      37              : {
      38            2 :   struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
      39            2 :     .header.size = htons (sizeof (ev)),
      40            2 :     .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
      41              :     .h_wire = *h_wire
      42              :   };
      43            2 :   struct GNUNET_DB_EventHeaderP hdr = {
      44            2 :     .size = htons (sizeof (hdr)),
      45            2 :     .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
      46              :   };
      47              :   char *notify_s
      48            2 :     = GNUNET_PQ_get_event_notify_channel (&ev.header);
      49              :   char *notify2_s
      50            2 :     = GNUNET_PQ_get_event_notify_channel (&hdr);
      51            2 :   uint32_t http_status32 = (uint32_t) exchange_http_status;
      52            2 :   struct GNUNET_PQ_QueryParam params[] = {
      53            2 :     GNUNET_PQ_query_param_auto_from_type (h_wire),
      54            2 :     GNUNET_PQ_query_param_string (exchange_url),
      55            2 :     GNUNET_PQ_query_param_timestamp (&timestamp),
      56            2 :     GNUNET_PQ_query_param_uint32 (&http_status32),
      57            2 :     GNUNET_PQ_query_param_bool (kyc_ok),
      58            2 :     GNUNET_PQ_query_param_string (notify_s),
      59            2 :     GNUNET_PQ_query_param_string (notify2_s),
      60              :     GNUNET_PQ_query_param_end
      61              :   };
      62              :   bool no_account;
      63            2 :   struct GNUNET_PQ_ResultSpec rs[] = {
      64            2 :     GNUNET_PQ_result_spec_bool ("no_account",
      65              :                                 &no_account),
      66              :     GNUNET_PQ_result_spec_end
      67              :   };
      68              :   enum GNUNET_DB_QueryStatus qs;
      69              : 
      70            2 :   GNUNET_assert (NULL != pg->current_merchant_id);
      71            2 :   GNUNET_assert (0 == strcmp (merchant_id,
      72              :                               pg->current_merchant_id));
      73            2 :   TMH_PQ_prepare_anon (pg,
      74              :                        "SELECT "
      75              :                        "  out_no_account AS no_account"
      76              :                        " FROM merchant_do_account_kyc_set_failed"
      77              :                        "($1, $2, $3, $4, $5, $6, $7);");
      78            2 :   qs = GNUNET_PQ_eval_prepared_singleton_select (
      79              :     pg->conn,
      80              :     "",
      81              :     params,
      82              :     rs);
      83            2 :   GNUNET_free (notify_s);
      84            2 :   GNUNET_free (notify2_s);
      85            2 :   if (qs <= 0)
      86              :   {
      87            0 :     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
      88            0 :     GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
      89            0 :     GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
      90            0 :     return qs;
      91              :   }
      92            2 :   GNUNET_break (! no_account);
      93            2 :   return qs;
      94              : }
        

Generated by: LCOV version 2.0-1