donau

Donation authority for GNU Taler (experimental)
Log | Files | Refs | Submodules | README | LICENSE

commit ef4a622a6aa5d3064f89be37b56d1dc48eb2bd40
parent 7b6c5c0680bc1130b38799be323dedb9e497ec15
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
Date:   Fri,  5 Jan 2024 18:18:48 +0100

added charity pg lookup

Diffstat:
Msrc/donau/donau-httpd_get-charity.c | 14+++++++-------
Asrc/donaudb/pg_lookup_charity.c | 57+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/donaudb/pg_lookup_charity.h | 40++++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/src/donau/donau-httpd_get-charity.c b/src/donau/donau-httpd_get-charity.c @@ -100,17 +100,17 @@ DH_handler_charity_get ( } result = TALER_MHD_REPLY_JSON_PACK ( - connection, - http_status, - TALER_MHD_PACK_EC (ec), - GNUNET_JSON_pack_string ("url", + connection, + http_status, + TALER_MHD_PACK_EC (ec), + GNUNET_JSON_pack_string ("url", charity_url), GNUNET_JSON_pack_string ("name", charity_name)); - GNUNET_free(charity_url); - GNUNET_free(charity_name); - return result + GNUNET_free (charity_url); + GNUNET_free (charity_name); + return result; } } diff --git a/src/donaudb/pg_lookup_charity.c b/src/donaudb/pg_lookup_charity.c @@ -0,0 +1,57 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of CHARITYABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file donaudb/pg_lookup_donation_unit_key.c + * @brief Implementation of the lookup_donation_unit_key function for Postgres + * @author Johannes Casaburi + */ +#include "taler/platform.h" +#include "taler/taler_error_codes.h" +#include "taler/taler_dbevents.h" +#include "taler/taler_pq_lib.h" +#include "pg_lookup_charity.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +DH_PG_lookup_charity ( + void *cls, + struct DONAUDB_CharityMetaData *meta) +{ + struct PostgresClosure *pg = cls; + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_uint64 (charity_id), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_query_param_string ("charity_url", + &meta->charity_url), + GNUNET_PQ_query_param_string ("charity_name", + &meta->charity_name), + GNUNET_PQ_result_spec_end + }; + + PREPARE (pg, + "lookup_charity", + "SELECT " + " charity_name" + " ,charity_url" + " FROM charities" + " WHERE charity_id=$1;"); + return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, + "lookup_charity", + params, + rs); +} diff --git a/src/donaudb/pg_lookup_charity.h b/src/donaudb/pg_lookup_charity.h @@ -0,0 +1,40 @@ +/* + This file is part of TALER + Copyright (C) 2024 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of CHARITYABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file donaudb/pg_lookup_charity.h + * @brief implementation of the lookup_charity function for Postgres + * @author Johannes Casaburi + */ +#ifndef PG_GET_DONATION_UNIT_INFO_H +#define PG_GET_DONATION_UNIT_INFO_H + +#include <taler/taler_util.h> +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" +/** + * Fetch information about a donation unit key. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param donation_unit_pub_hash hash of the public key + * @param[out] info information with value and other info about the coin + * @return transaction status code + */ +enum GNUNET_DB_QueryStatus +DH_PG_lookup_charity ( + void *cls, + struct DONAUDB_CharityMetaData *meta); + +#endif