LCOV - code coverage report
Current view: top level - backenddb - pg_account_kyc_set_status.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 40 44 90.9 %
Date: 2025-06-23 16:22:09 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :    This file is part of TALER
       3             :    Copyright (C) 2022-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 backenddb/pg_account_kyc_set_status.c
      18             :  * @brief Implementation of the account_kyc_set_status function for Postgres
      19             :  * @author Iván Ávalos
      20             :  * @author Christian Grothoff
      21             :  */
      22             : #include "platform.h"
      23             : #include <taler/taler_error_codes.h>
      24             : #include <taler/taler_dbevents.h>
      25             : #include <taler/taler_pq_lib.h>
      26             : #include "pg_account_kyc_set_status.h"
      27             : #include "pg_helper.h"
      28             : 
      29             : 
      30             : enum GNUNET_DB_QueryStatus
      31          14 : TMH_PG_account_kyc_set_status (
      32             :   void *cls,
      33             :   const char *merchant_id,
      34             :   const struct TALER_MerchantWireHashP *h_wire,
      35             :   const char *exchange_url,
      36             :   struct GNUNET_TIME_Timestamp timestamp,
      37             :   unsigned int exchange_http_status,
      38             :   enum TALER_ErrorCode exchange_ec_code,
      39             :   uint64_t rule_gen,
      40             :   const struct TALER_AccountAccessTokenP *access_token,
      41             :   const json_t *jlimits,
      42             :   bool in_aml_review,
      43             :   bool kyc_ok)
      44             : {
      45          14 :   struct PostgresClosure *pg = cls;
      46          14 :   struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
      47          14 :     .header.size = htons (sizeof (ev)),
      48          14 :     .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
      49             :     .h_wire = *h_wire
      50             :   };
      51          14 :   struct GNUNET_DB_EventHeaderP hdr = {
      52          14 :     .size = htons (sizeof (hdr)),
      53          14 :     .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED)
      54             :   };
      55             :   char *notify_s
      56          14 :     = GNUNET_PQ_get_event_notify_channel (&ev.header);
      57             :   char *notify2_s
      58          14 :     = GNUNET_PQ_get_event_notify_channel (&hdr);
      59          14 :   uint32_t http_status32 = (uint32_t) exchange_http_status;
      60          14 :   uint32_t ec_code32 = (uint32_t) exchange_ec_code;
      61          14 :   struct GNUNET_PQ_QueryParam params[] = {
      62          14 :     GNUNET_PQ_query_param_string (merchant_id),
      63          14 :     GNUNET_PQ_query_param_auto_from_type (h_wire),
      64          14 :     GNUNET_PQ_query_param_string (exchange_url),
      65          14 :     GNUNET_PQ_query_param_timestamp (&timestamp),
      66          14 :     GNUNET_PQ_query_param_uint32 (&http_status32),
      67          14 :     GNUNET_PQ_query_param_uint32 (&ec_code32),
      68             :     NULL != access_token
      69           2 :     ? GNUNET_PQ_query_param_auto_from_type (access_token)
      70          14 :     : GNUNET_PQ_query_param_null (),
      71             :     NULL != jlimits
      72           2 :     ? TALER_PQ_query_param_json (jlimits)
      73          14 :     : GNUNET_PQ_query_param_null (),
      74          14 :     GNUNET_PQ_query_param_bool (in_aml_review),
      75          14 :     GNUNET_PQ_query_param_bool (kyc_ok),
      76          14 :     GNUNET_PQ_query_param_string (notify_s),
      77          14 :     GNUNET_PQ_query_param_string (notify2_s),
      78          14 :     GNUNET_PQ_query_param_uint64 (&rule_gen),
      79             :     GNUNET_PQ_query_param_end
      80             :   };
      81             :   bool no_instance;
      82             :   bool no_account;
      83          14 :   struct GNUNET_PQ_ResultSpec rs[] = {
      84          14 :     GNUNET_PQ_result_spec_bool ("no_instance",
      85             :                                 &no_instance),
      86          14 :     GNUNET_PQ_result_spec_bool ("no_account",
      87             :                                 &no_account),
      88             :     GNUNET_PQ_result_spec_end
      89             :   };
      90             :   enum GNUNET_DB_QueryStatus qs;
      91             : 
      92          14 :   check_connection (pg);
      93          14 :   PREPARE (pg,
      94             :            "account_kyc_set_status",
      95             :            "SELECT "
      96             :            "  out_no_instance AS no_instance"
      97             :            " ,out_no_account AS no_account"
      98             :            " FROM merchant_do_account_kyc_set_status"
      99             :            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13);");
     100          14 :   qs = GNUNET_PQ_eval_prepared_singleton_select (
     101             :     pg->conn,
     102             :     "account_kyc_set_status",
     103             :     params,
     104             :     rs);
     105          14 :   GNUNET_free (notify_s);
     106          14 :   GNUNET_free (notify2_s);
     107          14 :   if (qs <= 0)
     108             :   {
     109           0 :     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
     110           0 :     GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
     111           0 :     GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs);
     112           0 :     return qs;
     113             :   }
     114          14 :   GNUNET_break (! no_instance);
     115          14 :   GNUNET_break (! no_account);
     116          14 :   return qs;
     117             : }

Generated by: LCOV version 1.16