summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_tip-query.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-24 13:00:12 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-24 13:00:12 +0100
commit80c44a5279babccf1626534dc362f4d11a6bbc7a (patch)
treec622cdc80f5e383e8eb21af61d0fcbc76221b4b7 /src/backend/taler-merchant-httpd_tip-query.c
parent6362ade0e6ee926beab51000ad27ae3d2bcb190c (diff)
downloadmerchant-80c44a5279babccf1626534dc362f4d11a6bbc7a.tar.gz
merchant-80c44a5279babccf1626534dc362f4d11a6bbc7a.tar.bz2
merchant-80c44a5279babccf1626534dc362f4d11a6bbc7a.zip
more deduplication via libtalermhd
Diffstat (limited to 'src/backend/taler-merchant-httpd_tip-query.c')
-rw-r--r--src/backend/taler-merchant-httpd_tip-query.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/src/backend/taler-merchant-httpd_tip-query.c b/src/backend/taler-merchant-httpd_tip-query.c
index aad183a7..649d1d31 100644
--- a/src/backend/taler-merchant-httpd_tip-query.c
+++ b/src/backend/taler-merchant-httpd_tip-query.c
@@ -26,7 +26,6 @@
#include "taler-merchant-httpd.h"
#include "taler-merchant-httpd_mhd.h"
#include "taler-merchant-httpd_exchanges.h"
-#include "taler-merchant-httpd_responses.h"
#include "taler-merchant-httpd_tip-query.h"
#include "taler-merchant-httpd_tip-reserve-helper.h"
@@ -103,28 +102,29 @@ generate_final_response (struct TipQueryContext *tqc)
"amount overflow, deposited %s but withdrawn %s\n",
TALER_amount_to_string (&tqc->ctr.amount_deposited),
TALER_amount_to_string (&tqc->ctr.amount_withdrawn));
- return TMH_RESPONSE_reply_internal_error (tqc->ctr.connection,
- TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_INCONSISTENT,
- "Exchange returned invalid reserve history (amount overflow)");
+ return TALER_MHD_reply_with_error (tqc->ctr.connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_TIP_QUERY_RESERVE_HISTORY_ARITHMETIC_ISSUE_INCONSISTENT,
+ "Exchange returned invalid reserve history (amount overflow)");
}
- return TMH_RESPONSE_reply_json_pack (tqc->ctr.connection,
- MHD_HTTP_OK,
- "{s:o, s:o, s:o, s:o, s:o}",
- "reserve_pub",
- GNUNET_JSON_from_data_auto (
- &reserve_pub),
- "reserve_expiration",
- GNUNET_JSON_from_time_abs (
- tqc->ctr.reserve_expiration),
- "amount_authorized",
- TALER_JSON_from_amount (
- &tqc->ctr.amount_authorized),
- "amount_picked_up",
- TALER_JSON_from_amount (
- &tqc->ctr.amount_withdrawn),
- "amount_available",
- TALER_JSON_from_amount (
- &amount_available));
+ return TALER_MHD_reply_json_pack (tqc->ctr.connection,
+ MHD_HTTP_OK,
+ "{s:o, s:o, s:o, s:o, s:o}",
+ "reserve_pub",
+ GNUNET_JSON_from_data_auto (
+ &reserve_pub),
+ "reserve_expiration",
+ GNUNET_JSON_from_time_abs (
+ tqc->ctr.reserve_expiration),
+ "amount_authorized",
+ TALER_JSON_from_amount (
+ &tqc->ctr.amount_authorized),
+ "amount_picked_up",
+ TALER_JSON_from_amount (
+ &tqc->ctr.amount_withdrawn),
+ "amount_available",
+ TALER_JSON_from_amount (
+ &amount_available));
}
@@ -195,9 +195,10 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Instance `%s' not configured for tipping\n",
mi->id);
- return TMH_RESPONSE_reply_not_found (connection,
- TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP,
- "exchange for tipping not configured for the instance");
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_TIP_AUTHORIZE_INSTANCE_DOES_NOT_TIP,
+ "exchange for tipping not configured for the instance");
}
tqc->ctr.reserve_priv = mi->tip_reserve;
@@ -216,9 +217,10 @@ MH_handler_tip_query (struct TMH_RequestHandler *rh,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Database hard error on get_authorized_tip_amount\n");
- return TMH_RESPONSE_reply_internal_error (connection,
- TALER_EC_TIP_QUERY_DB_ERROR,
- "Merchant database error");
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_TIP_QUERY_DB_ERROR,
+ "Merchant database error");
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
{