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