summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-06-22 20:30:25 +0200
committerChristian Grothoff <christian@grothoff.org>2020-06-22 20:30:25 +0200
commit0748ecde7be1fb9537382d7cadc38031fbc696ff (patch)
tree9e4d6dbacb1e7d0c48d27e8f441f497d3a0f6cef
parentd83304e2a3af18480e3c83077c54a1b532904d2b (diff)
downloadmerchant-0748ecde7be1fb9537382d7cadc38031fbc696ff.tar.gz
merchant-0748ecde7be1fb9537382d7cadc38031fbc696ff.tar.bz2
merchant-0748ecde7be1fb9537382d7cadc38031fbc696ff.zip
return active-status of reserves from backenddb (fixes FIXMEs)
-rw-r--r--src/backend/taler-merchant-httpd_private-get-reserves-ID.c7
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c22
-rw-r--r--src/include/taler_merchant_service.h2
-rw-r--r--src/include/taler_merchantdb_plugin.h2
-rw-r--r--src/lib/merchant_api_get_reserve.c6
-rw-r--r--src/testing/testing_api_cmd_get_reserve.c1
6 files changed, 30 insertions, 10 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
index 7e7c14a9..1945524a 100644
--- a/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-reserves-ID.c
@@ -62,6 +62,7 @@ struct GetReserveContext
* @param picked_up_amount total of tips that were picked up from this reserve
* @param committed_amount total of tips that the merchant committed to, but that were not
* picked up yet
+ * @param active true if the reserve is still active (we have the private key)
* @param tips_length length of the @a tips array
* @param tips information about the tips created by this reserve
*/
@@ -73,6 +74,7 @@ handle_reserve_details (void *cls,
const struct TALER_Amount *exchange_initial_amount,
const struct TALER_Amount *picked_up_amount,
const struct TALER_Amount *committed_amount,
+ bool active,
unsigned int tips_length,
const struct TALER_MERCHANTDB_TipDetails *tips)
{
@@ -112,14 +114,15 @@ handle_reserve_details (void *cls,
ctx->res = TALER_MHD_reply_json_pack (
ctx->connection,
MHD_HTTP_OK,
- "{s:o, s:o, s:o, s:o, s:o, s:o, s:o?}",
+ "{s:o, s:o, s:o, s:o, s:o, s:o, s:o?, s:b}",
"creation_time", GNUNET_JSON_from_time_abs (creation_time_round),
"expiration_time", GNUNET_JSON_from_time_abs (expiration_time_round),
"merchant_initial_amount", TALER_JSON_from_amount (merchant_initial_amount),
"exchange_initial_amount", TALER_JSON_from_amount (exchange_initial_amount),
"pickup_amount", TALER_JSON_from_amount (picked_up_amount),
"committed_amount", TALER_JSON_from_amount (committed_amount),
- "tips", tips_json);
+ "tips", tips_json,
+ "active", active);
}
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 54719940..fc1e3acc 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -4341,7 +4341,7 @@ lookup_reserves_cb (void *cls,
struct TALER_Amount exchange_initial_balance;
struct TALER_Amount pickup_amount;
struct TALER_Amount committed_amount;
- uint8_t active = 0;
+ uint8_t active;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("reserve_pub",
&reserve_pub),
@@ -4357,8 +4357,8 @@ lookup_reserves_cb (void *cls,
&committed_amount),
TALER_PQ_RESULT_SPEC_AMOUNT ("tips_picked_up",
&pickup_amount),
- /*GNUNET_PQ_result_spec_auto_from_type ("active",
- &active), FIXME: 'active'*/
+ GNUNET_PQ_result_spec_auto_from_type ("active",
+ &active),
GNUNET_PQ_result_spec_end
};
@@ -4374,10 +4374,10 @@ lookup_reserves_cb (void *cls,
switch (lrc->active)
{
case TALER_EXCHANGE_YNA_YES:
- if (! active)
+ if (0 == active)
continue;
case TALER_EXCHANGE_YNA_NO:
- if (active)
+ if (0 != active)
continue;
case TALER_EXCHANGE_YNA_ALL:
break;
@@ -4682,7 +4682,7 @@ postgres_lookup_reserve (void *cls,
struct TALER_Amount exchange_initial_balance;
struct TALER_Amount pickup_amount;
struct TALER_Amount committed_amount;
- /*uint8_t active;*/
+ uint8_t active;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_absolute_time ("creation_time",
&creation_time),
@@ -4696,8 +4696,8 @@ postgres_lookup_reserve (void *cls,
&pickup_amount),
TALER_PQ_RESULT_SPEC_AMOUNT ("tips_committed",
&committed_amount),
- /*GNUNET_PQ_result_spec_auto_from_type ("active",
- &active), FIXME: active! */
+ GNUNET_PQ_result_spec_auto_from_type ("active",
+ &active),
GNUNET_PQ_result_spec_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -4718,6 +4718,7 @@ postgres_lookup_reserve (void *cls,
&exchange_initial_balance,
&pickup_amount,
&committed_amount,
+ (0 != active),
0,
NULL);
return qs;
@@ -4739,6 +4740,7 @@ postgres_lookup_reserve (void *cls,
&exchange_initial_balance,
&pickup_amount,
&committed_amount,
+ 0 != active,
ltc.tips_length,
ltc.tips);
}
@@ -7789,7 +7791,9 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
",tips_committed_frac"
",tips_picked_up_val"
",tips_picked_up_frac"
+ ",reserve_priv IS NOT NULL AS active"
" FROM merchant_tip_reserves"
+ " FULL OUTER JOIN merchant_tip_reserve_keys USING (reserve_serial)"
" WHERE creation_time > $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
@@ -7823,7 +7827,9 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
",tips_committed_frac"
",tips_picked_up_val"
",tips_picked_up_frac"
+ ",reserve_priv IS NOT NULL AS active"
" FROM merchant_tip_reserves"
+ " FULL OUTER JOIN merchant_tip_reserve_keys USING (reserve_serial)"
" WHERE reserve_pub = $2"
" AND merchant_serial ="
" (SELECT merchant_serial"
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 23d0bbeb..b6cd6815 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -2593,6 +2593,7 @@ struct TALER_MERCHANT_TipDetails
* @param cls closure
* @param hr HTTP response details
* @param rs reserve summary for the reserve, NULL on error
+ * @param active is this reserve active (false if it was deleted but not purged)
* @param tips_length length of the @a reserves array
* @param tips array with details about the tips granted, NULL on error
*/
@@ -2601,6 +2602,7 @@ typedef void
void *cls,
const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_ReserveSummary *rs,
+ bool active,
unsigned int tips_length,
const struct TALER_MERCHANT_TipDetails tips[]);
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index 18cb03e5..b1dafec6 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -557,6 +557,7 @@ typedef void
* @param picked_up_amount total of tips that were picked up from this reserve
* @param committed_amount total of tips that the merchant committed to, but that were not
* picked up yet
+ * @param active true if the reserve is still active (we have the private key)
* @param tips_length length of the @a tips array
* @param tips information about the tips created by this reserve
*/
@@ -569,6 +570,7 @@ typedef void
const struct TALER_Amount *exchange_initial_amount,
const struct TALER_Amount *picked_up_amount,
const struct TALER_Amount *committed_amount,
+ bool active,
unsigned int tips_length,
const struct TALER_MERCHANTDB_TipDetails *tips);
diff --git a/src/lib/merchant_api_get_reserve.c b/src/lib/merchant_api_get_reserve.c
index f92f37f9..3ff14d41 100644
--- a/src/lib/merchant_api_get_reserve.c
+++ b/src/lib/merchant_api_get_reserve.c
@@ -83,6 +83,7 @@ handle_reserve_get_finished (void *cls,
.http_status = (unsigned int) response_code,
.reply = json
};
+ bool active;
rgh->job = NULL;
switch (response_code)
@@ -99,6 +100,8 @@ handle_reserve_get_finished (void *cls,
&rs.creation_time),
GNUNET_JSON_spec_absolute_time ("expiration_time",
&rs.expiration_time),
+ GNUNET_JSON_spec_bool ("active",
+ &active),
TALER_JSON_spec_amount ("merchant_initial_amount",
&rs.merchant_initial_amount),
TALER_JSON_spec_amount ("exchange_initial_amount",
@@ -129,6 +132,7 @@ handle_reserve_get_finished (void *cls,
rgh->cb (rgh->cb_cls,
&hr,
&rs,
+ false,
0,
NULL);
TALER_MERCHANT_reserve_get_cancel (rgh);
@@ -186,6 +190,7 @@ handle_reserve_get_finished (void *cls,
rgh->cb (rgh->cb_cls,
&hr,
&rs,
+ active,
tds_length,
tds);
GNUNET_free (tds);
@@ -215,6 +220,7 @@ handle_reserve_get_finished (void *cls,
rgh->cb (rgh->cb_cls,
&hr,
NULL,
+ false,
0,
NULL);
TALER_MERCHANT_reserve_get_cancel (rgh);
diff --git a/src/testing/testing_api_cmd_get_reserve.c b/src/testing/testing_api_cmd_get_reserve.c
index 8a26a9a9..8c626f82 100644
--- a/src/testing/testing_api_cmd_get_reserve.c
+++ b/src/testing/testing_api_cmd_get_reserve.c
@@ -72,6 +72,7 @@ static void
get_reserve_cb (void *cls,
const struct TALER_MERCHANT_HttpResponse *hr,
const struct TALER_MERCHANT_ReserveSummary *rs,
+ bool active,
unsigned int tips_length,
const struct TALER_MERCHANT_TipDetails tips[])
{