From fe19d9ada3f6dfdf3014b9610090b8750de32db8 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 21 May 2020 23:06:59 +0200 Subject: towards POST tips pickup impl --- .../taler-merchant-httpd_private-get-tips-ID.c | 94 +++++++++++++++------- 1 file changed, 64 insertions(+), 30 deletions(-) (limited to 'src/backend/taler-merchant-httpd_private-get-tips-ID.c') diff --git a/src/backend/taler-merchant-httpd_private-get-tips-ID.c b/src/backend/taler-merchant-httpd_private-get-tips-ID.c index f186363d..6276189f 100644 --- a/src/backend/taler-merchant-httpd_private-get-tips-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-tips-ID.c @@ -42,14 +42,17 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, struct MHD_Connection *connection, struct TMH_HandlerContext *hc) { - char *exchange_url; struct GNUNET_HashCode tip_id; - struct TALER_Amount tip_amount; - struct TALER_Amount tip_amount_left; - struct GNUNET_TIME_Absolute timestamp; + struct TALER_Amount total_authorized; + struct TALER_Amount total_picked_up; + char *reason; + struct GNUNET_TIME_Absolute expiration; + unsigned int pickups_length = 0; + struct TALER_MERCHANTDB_PickupDetails *pickups = NULL; struct GNUNET_TIME_Absolute timestamp_expire; - MHD_RESULT ret; enum GNUNET_DB_QueryStatus qs; + bool fpu; + json_t *pickups_json; GNUNET_assert (NULL != hc->infix); if (GNUNET_OK != @@ -63,17 +66,27 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, TALER_EC_PARAMETER_MALFORMED, "tip_id malformed"); } + { + const char *pstr; + pstr = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "pickups"); + fpu = (NULL != pstr) ? 0 == strcasecmp (pstr, "yes") : + false; + } db->preflight (db->cls); - // FIXME: logic here is completely bonkers! - qs = db->lookup_tip_by_id (db->cls, - &tip_id, - &exchange_url, - &extra, - &tip_amount, - &tip_amount_left, - ×tamp); - + qs = db->lookup_tip_details (db->cls, + hc->instance->settings.id, + &tip_id, + fpu, + &total_authorized, + &total_picked_up, + &reason, + &expiration, + &reserve_pub, + &pickups_length, + &pickups); if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) { unsigned int response_code; @@ -104,21 +117,42 @@ TMH_private_get_tips_ID (const struct TMH_RequestHandler *rh, ec, "Could not determine exchange URL for the given tip id"); } + if (fpu) + { + pickups_json = json_array (); + GNUNET_assert (NULL != pickups_json); + for (unsigned int i = 0; i