pg_activate_account.c (3252B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022 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_activate_account.c 18 * @brief Implementation of the activate_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_activate_account.h" 26 #include "pg_helper.h" 27 28 29 enum GNUNET_DB_QueryStatus 30 TMH_PG_activate_account ( 31 void *cls, 32 const struct TALER_MERCHANTDB_AccountDetails *account_details, 33 struct TALER_MerchantWireHashP *h_wire, 34 struct TALER_WireSaltP *salt, 35 bool *not_found, 36 bool *conflict) 37 { 38 struct PostgresClosure *pg = cls; 39 struct GNUNET_PQ_QueryParam params[] = { 40 GNUNET_PQ_query_param_string (account_details->instance_id), 41 GNUNET_PQ_query_param_auto_from_type (&account_details->h_wire), 42 GNUNET_PQ_query_param_auto_from_type (&account_details->salt), 43 GNUNET_PQ_query_param_string (account_details->payto_uri.full_payto), 44 NULL ==account_details->credit_facade_url 45 ? GNUNET_PQ_query_param_null () 46 : GNUNET_PQ_query_param_string (account_details->credit_facade_url), 47 NULL == account_details->credit_facade_credentials 48 ? GNUNET_PQ_query_param_null () 49 : TALER_PQ_query_param_json (account_details->credit_facade_credentials), 50 NULL == account_details->extra_wire_subject_metadata 51 ? GNUNET_PQ_query_param_null () 52 : GNUNET_PQ_query_param_string ( 53 account_details->extra_wire_subject_metadata), 54 GNUNET_PQ_query_param_end 55 }; 56 struct GNUNET_PQ_ResultSpec rs[] = { 57 GNUNET_PQ_result_spec_bool ("not_found", 58 not_found), 59 GNUNET_PQ_result_spec_bool ("conflict", 60 conflict), 61 GNUNET_PQ_result_spec_auto_from_type ("h_wire", 62 h_wire), 63 GNUNET_PQ_result_spec_auto_from_type ("salt", 64 salt), 65 GNUNET_PQ_result_spec_end 66 }; 67 68 GNUNET_assert (account_details->active); 69 check_connection (pg); 70 PREPARE (pg, 71 "activate_account", 72 "SELECT " 73 " out_h_wire AS h_wire" 74 " ,out_salt AS salt" 75 " ,out_conflict AS conflict" 76 " ,out_not_found AS not_found" 77 " FROM merchant_do_activate_account" 78 " ($1,$2,$3,$4,$5,$6,$7);"); 79 return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 80 "activate_account", 81 params, 82 rs); 83 }