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