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 backenddb/pg_account_kyc_set_failed.c 18 : * @brief Implementation of the account_kyc_set_failed function for Postgres 19 : * @author Christian Grothoff 20 : */ 21 : #include "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_account_kyc_set_failed.h" 26 : #include "pg_helper.h" 27 : 28 : 29 : enum GNUNET_DB_QueryStatus 30 0 : TMH_PG_account_kyc_set_failed ( 31 : void *cls, 32 : const char *merchant_id, 33 : const struct TALER_MerchantWireHashP *h_wire, 34 : const char *exchange_url, 35 : struct GNUNET_TIME_Timestamp timestamp, 36 : unsigned int exchange_http_status, 37 : bool kyc_ok) 38 : { 39 0 : struct PostgresClosure *pg = cls; 40 0 : struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = { 41 0 : .header.size = htons (sizeof (ev)), 42 0 : .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED), 43 : .h_wire = *h_wire 44 : }; 45 0 : struct GNUNET_DB_EventHeaderP hdr = { 46 0 : .size = htons (sizeof (hdr)), 47 0 : .type = htons (TALER_DBEVENT_MERCHANT_KYC_STATUS_CHANGED) 48 : }; 49 : char *notify_s 50 0 : = GNUNET_PQ_get_event_notify_channel (&ev.header); 51 : char *notify2_s 52 0 : = GNUNET_PQ_get_event_notify_channel (&hdr); 53 0 : uint32_t http_status32 = (uint32_t) exchange_http_status; 54 0 : struct GNUNET_PQ_QueryParam params[] = { 55 0 : GNUNET_PQ_query_param_string (merchant_id), 56 0 : GNUNET_PQ_query_param_auto_from_type (h_wire), 57 0 : GNUNET_PQ_query_param_string (exchange_url), 58 0 : GNUNET_PQ_query_param_timestamp (×tamp), 59 0 : GNUNET_PQ_query_param_uint32 (&http_status32), 60 0 : GNUNET_PQ_query_param_bool (kyc_ok), 61 0 : GNUNET_PQ_query_param_string (notify_s), 62 0 : GNUNET_PQ_query_param_string (notify2_s), 63 : GNUNET_PQ_query_param_end 64 : }; 65 : bool no_instance; 66 : bool no_account; 67 0 : struct GNUNET_PQ_ResultSpec rs[] = { 68 0 : GNUNET_PQ_result_spec_bool ("no_instance", 69 : &no_instance), 70 0 : GNUNET_PQ_result_spec_bool ("no_account", 71 : &no_account), 72 : GNUNET_PQ_result_spec_end 73 : }; 74 : enum GNUNET_DB_QueryStatus qs; 75 : 76 0 : check_connection (pg); 77 0 : PREPARE (pg, 78 : "account_kyc_set_failed", 79 : "SELECT " 80 : " out_no_instance AS no_instance" 81 : " ,out_no_account AS no_account" 82 : " FROM merchant_do_account_kyc_set_failed" 83 : "($1, $2, $3, $4, $5, $6, $7, $8, $9);"); 84 0 : qs = GNUNET_PQ_eval_prepared_singleton_select ( 85 : pg->conn, 86 : "account_kyc_set_failed", 87 : params, 88 : rs); 89 0 : GNUNET_free (notify_s); 90 0 : GNUNET_free (notify2_s); 91 0 : if (qs <= 0) 92 : { 93 0 : GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs); 94 0 : GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs); 95 0 : GNUNET_break (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != qs); 96 0 : return qs; 97 : } 98 0 : GNUNET_break (! no_instance); 99 0 : GNUNET_break (! no_account); 100 0 : return qs; 101 : }