commit f03408b164a89df624e9e0fc251cf6cb74413ed6
parent fea2ab501c80d7de1045d6d6f0422b56f0b9d8a4
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date: Fri, 25 Jul 2025 16:41:26 +0200
Merge branch 'dev/bohdan-potuzhnyi/donau-integration' of ssh://git.taler.net/merchant into dev/bohdan-potuzhnyi/donau-integration
Diffstat:
4 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -754,7 +754,7 @@ struct PayContext
struct DONAU_BlindedDonationUnitSignature *sigs;
/**
- * Number of receipts @e sigs for the donations from the Donau.
+ * Number of receipts in @e sigs for the donations from the Donau.
*/
unsigned int num_sigs;
@@ -1995,13 +1995,14 @@ phase_process_donation_receipt (struct PayContext *pc)
* is malformed.
*/
static void
-signatures_to_json (const size_t num_sig,
- struct DONAU_BlindedDonationUnitSignature *signatures,
- json_t *j_signatures)
+signatures_to_json (size_t num_sig,
+ const struct DONAU_BlindedDonationUnitSignature *signatures,
+ json_t *j_signatures)
{
for (size_t i = 0; i < num_sig; i++)
{
- struct DONAU_BlindedDonationUnitSignature *signature = &signatures[i];
+ const struct DONAU_BlindedDonationUnitSignature *signature = &signatures[i];
+
GNUNET_assert (
0 == json_array_append (
j_signatures,
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -78,7 +78,7 @@
* refuses a forced download.
*/
#define MAX_KEYS_WAIT \
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2500)
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2500)
/**
* Generate the base URL for the given merchant instance.
@@ -3229,20 +3229,14 @@ phase_merge_inventory (struct OrderContext *oc)
* It simply adds the provided donau_url to the json.
*
* @param cls closure with our `struct TALER_MERCHANT_ContractOutput *`
+ * @param donau_url the URL of the donau instance
*/
static void
add_donau_url (void *cls,
- const char *donau_url,
- const struct TALER_Amount *charity_max_per_year)
+ const char *donau_url)
{
struct TALER_MERCHANT_ContractOutput *output = cls;
- if ( (NULL == charity_max_per_year) ||
- (GNUNET_OK !=
- TALER_amount_cmp_currency (&output->details.donation_receipt.amount,
- charity_max_per_year)) )
- return;
-
GNUNET_array_append (output->details.donation_receipt.donau_urls,
output->details.donation_receipt.donau_urls_len,
GNUNET_strdup (donau_url));
@@ -3250,9 +3244,12 @@ add_donau_url (void *cls,
/**
+ * Add the donau output to the contract output.
*
+ * @param oc order context
+ * @param output contract output to add donau URLs to
*/
-static void
+static bool
add_donau_output (struct OrderContext *oc,
struct TALER_MERCHANT_ContractOutput *output)
{
@@ -3261,19 +3258,19 @@ add_donau_output (struct OrderContext *oc,
/* Invoke the database call, accumulating URLs in a JSON array */
qs = TMH_db->select_donau_instances_filtered (
TMH_db->cls,
+ output->details.donation_receipt.amount.currency,
&add_donau_url,
output);
-
- /* REVIEW: If no switch */
if (qs < 0)
{
- GNUNET_break_op (0);
+ GNUNET_break (0);
reply_with_error (oc,
MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_CLIENT_INTERNAL_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
"donau url parsing db call");
- return;
+ return false;
}
+ return true;
}
@@ -3476,8 +3473,12 @@ phase_parse_choices (struct OrderContext *oc)
case TALER_MERCHANT_CONTRACT_OUTPUT_TYPE_DONATION_RECEIPT:
output.details.donation_receipt.amount = choice->amount;
#ifdef HAVE_DONAU_DONAU_SERVICE_H
- add_donau_output (oc,
- &output);
+ if (! add_donau_output (oc,
+ &output))
+ {
+ GNUNET_break (0);
+ return;
+ }
#endif
GNUNET_array_append (choice->outputs,
diff --git a/src/backenddb/pg_select_donau_instances_filtered.c b/src/backenddb/pg_select_donau_instances_filtered.c
@@ -67,13 +67,9 @@ select_donau_instance_cb (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
char *donau_url;
- struct TALER_Amount charity_max_per_year;
-
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_string ("donau_url",
&donau_url),
- TALER_PQ_result_spec_amount_with_currency ("charity_max_per_year",
- &charity_max_per_year),
GNUNET_PQ_result_spec_end
};
@@ -87,8 +83,7 @@ select_donau_instance_cb (void *cls,
return;
}
sdc->cb (sdc->cb_cls,
- donau_url,
- &charity_max_per_year);
+ donau_url);
GNUNET_PQ_cleanup_result (rs);
}
}
@@ -97,6 +92,7 @@ select_donau_instance_cb (void *cls,
enum GNUNET_DB_QueryStatus
TMH_PG_select_donau_instances_filtered (
void *cls,
+ const char *currency,
TALER_MERCHANTDB_DonauInstanceFilteredCallback cb,
void *cb_cls)
{
@@ -109,6 +105,7 @@ TMH_PG_select_donau_instances_filtered (
};
struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_string (currency),
GNUNET_PQ_query_param_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -117,9 +114,9 @@ TMH_PG_select_donau_instances_filtered (
PREPARE (pg,
"select_donau_instances_filtered",
"SELECT"
- " di.donau_url"
- ",di.charity_max_per_year"
- " FROM merchant_donau_instances di");
+ " donau_url"
+ " FROM merchant_donau_instances"
+ " WHERE (charity_max_per_year.curr)=$1");
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
"select_donau_instances_filtered",
@@ -132,4 +129,4 @@ TMH_PG_select_donau_instances_filtered (
return GNUNET_DB_STATUS_HARD_ERROR;
return qs;
-}
-\ No newline at end of file
+}
diff --git a/src/backenddb/pg_select_donau_instances_filtered.h b/src/backenddb/pg_select_donau_instances_filtered.h
@@ -32,6 +32,7 @@
* Select multiple Donau instances from the database.
*
* @param cls the closure for the database context
+ * @param currency currency to filter donau instances by
* @param cb callback function to call with each result
* @param cb_cls closure for the callback
* @return status of the PG
@@ -39,6 +40,7 @@
enum GNUNET_DB_QueryStatus
TMH_PG_select_donau_instances_filtered (
void *cls,
+ const char *currency,
TALER_MERCHANTDB_DonauInstanceFilteredCallback cb,
void *cb_cls);