pg_lookup_completed_legitimization.c (3257B)
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 exchangedb/pg_lookup_completed_legitimization.c 18 * @brief Implementation of the lookup_pending_legitimization function for Postgres 19 * @author Christian Grothoff 20 */ 21 #include "taler/taler_pq_lib.h" 22 #include "taler/exchange-database/lookup_completed_legitimization.h" 23 #include "helper.h" 24 25 26 enum GNUNET_DB_QueryStatus 27 TALER_EXCHANGEDB_lookup_completed_legitimization ( 28 struct TALER_EXCHANGEDB_PostgresContext *pg, 29 uint64_t legitimization_measure_serial_id, 30 uint32_t measure_index, 31 struct TALER_AccountAccessTokenP *access_token, 32 struct TALER_NormalizedPaytoHashP *h_payto, 33 bool *is_wallet, 34 json_t **jmeasures, 35 bool *is_finished, 36 size_t *encrypted_attributes_len, 37 void **encrypted_attributes 38 ) 39 { 40 struct GNUNET_PQ_QueryParam params[] = { 41 GNUNET_PQ_query_param_uint64 (&legitimization_measure_serial_id), 42 GNUNET_PQ_query_param_uint32 (&measure_index), 43 GNUNET_PQ_query_param_end 44 }; 45 struct GNUNET_PQ_ResultSpec rs[] = { 46 TALER_PQ_result_spec_json ( 47 "jmeasures", 48 jmeasures), 49 GNUNET_PQ_result_spec_auto_from_type ( 50 "h_normalized_payto", 51 h_payto), 52 GNUNET_PQ_result_spec_auto_from_type ( 53 "access_token", 54 access_token), 55 GNUNET_PQ_result_spec_bool ( 56 "is_finished", 57 is_finished), 58 GNUNET_PQ_result_spec_allow_null ( 59 GNUNET_PQ_result_spec_variable_size ( 60 "encrypted_attributes", 61 encrypted_attributes, 62 encrypted_attributes_len), 63 NULL), 64 GNUNET_PQ_result_spec_bool ( 65 "is_wallet", 66 is_wallet), 67 GNUNET_PQ_result_spec_end 68 }; 69 70 *encrypted_attributes_len = 0; 71 *encrypted_attributes = NULL; 72 PREPARE (pg, 73 "lookup_completed_legitimization", 74 "SELECT " 75 " lm.jmeasures::TEXT" 76 ",kt.h_normalized_payto" 77 ",kt.is_wallet" 78 ",lm.access_token" 79 ",lm.is_finished" 80 ",ka.encrypted_attributes" 81 " FROM legitimization_measures lm" 82 " JOIN kyc_targets kt" 83 " ON (lm.access_token = kt.access_token)" 84 " LEFT JOIN legitimization_processes lp" 85 " ON (lm.legitimization_measure_serial_id = lp.legitimization_measure_serial_id)" 86 " LEFT JOIN kyc_attributes ka" 87 " ON (ka.legitimization_serial = lp.legitimization_process_serial_id)" 88 " WHERE lm.legitimization_measure_serial_id=$1" 89 " AND lp.measure_index=$2;"); 90 return GNUNET_PQ_eval_prepared_singleton_select ( 91 pg->conn, 92 "lookup_completed_legitimization", 93 params, 94 rs); 95 }