activate_account.c (3345B)
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 src/backenddb/activate_account.c 18 * @brief Implementation of the activate_account function for Postgres 19 * @author Christian Grothoff 20 */ 21 #include "platform.h" 22 #include <taler/taler_pq_lib.h> 23 #include "merchant-database/activate_account.h" 24 #include "helper.h" 25 26 27 enum GNUNET_DB_QueryStatus 28 TALER_MERCHANTDB_activate_account ( 29 struct TALER_MERCHANTDB_PostgresContext *pg, 30 const struct TALER_MERCHANTDB_AccountDetails *account_details, 31 struct TALER_MerchantWireHashP *h_wire, 32 struct TALER_WireSaltP *salt, 33 bool *not_found, 34 bool *conflict) 35 { 36 struct GNUNET_PQ_QueryParam params[] = { 37 GNUNET_PQ_query_param_auto_from_type (&account_details->h_wire), 38 GNUNET_PQ_query_param_auto_from_type (&account_details->salt), 39 GNUNET_PQ_query_param_string (account_details->payto_uri.full_payto), 40 NULL ==account_details->credit_facade_url 41 ? GNUNET_PQ_query_param_null () 42 : GNUNET_PQ_query_param_string (account_details->credit_facade_url), 43 NULL == account_details->credit_facade_credentials 44 ? GNUNET_PQ_query_param_null () 45 : TALER_PQ_query_param_json (account_details->credit_facade_credentials), 46 NULL == account_details->extra_wire_subject_metadata 47 ? GNUNET_PQ_query_param_null () 48 : GNUNET_PQ_query_param_string ( 49 account_details->extra_wire_subject_metadata), 50 GNUNET_PQ_query_param_end 51 }; 52 struct GNUNET_PQ_ResultSpec rs[] = { 53 GNUNET_PQ_result_spec_bool ("not_found", 54 not_found), 55 GNUNET_PQ_result_spec_bool ("conflict", 56 conflict), 57 GNUNET_PQ_result_spec_auto_from_type ("h_wire", 58 h_wire), 59 GNUNET_PQ_result_spec_auto_from_type ("salt", 60 salt), 61 GNUNET_PQ_result_spec_end 62 }; 63 64 GNUNET_assert (account_details->active); 65 GNUNET_assert (NULL != pg->current_merchant_id); 66 GNUNET_assert (0 == strcmp (account_details->instance_id, 67 pg->current_merchant_id)); 68 check_connection (pg); 69 TMH_PQ_prepare_anon (pg, 70 "SELECT " 71 " out_h_wire AS h_wire" 72 " ,out_salt AS salt" 73 " ,out_conflict AS conflict" 74 " ,out_not_found AS not_found" 75 " FROM merchant_do_activate_account" 76 " ($1,$2,$3,$4,$5,$6);"); 77 return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, 78 "", 79 params, 80 rs); 81 }