summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-01-03 23:41:35 +0100
committerChristian Grothoff <christian@grothoff.org>2024-01-03 23:41:35 +0100
commit881381503f7f51b294c2740e9fcf7f28ef43f973 (patch)
tree97e1f648ac6007abfcf6a1a516ad75c082c91145 /src/backend
parent5284c114cfc2a0ba5cebf133228d338befae6d1a (diff)
downloadmerchant-881381503f7f51b294c2740e9fcf7f28ef43f973.tar.gz
merchant-881381503f7f51b294c2740e9fcf7f28ef43f973.tar.bz2
merchant-881381503f7f51b294c2740e9fcf7f28ef43f973.zip
simplify logic: only look in orders table if contracts table failed
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd_private-get-orders-ID.c68
1 files changed, 29 insertions, 39 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
index cd26d378..602a970f 100644
--- a/src/backend/taler-merchant-httpd_private-get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -763,16 +763,15 @@ phase_fetch_contract (struct GetOrderRequestContext *gorc)
"contract terms"));
return;
}
- if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
{
- gorc->order_only = true;
+ gorc->phase++;
+ return;
}
- /* FIXME: what is the point of doing the lookup_order
- below if order_only is false (qs == 1 above)?
- Seems we could just return here, or not? */
+ /* No contract, only order, fetch from orders table */
+ gorc->order_only = true;
{
struct TALER_MerchantPostDataHashP unused;
- json_t *ct = NULL;
/* We need the order for two cases: Either when the contract doesn't exist yet,
* or when the order is claimed but unpaid, and we need the claim token. */
@@ -781,39 +780,30 @@ phase_fetch_contract (struct GetOrderRequestContext *gorc)
hc->infix,
&gorc->claim_token,
&unused,
- &ct);
- if (0 > qs)
- {
- /* single, read-only SQL statements should never cause
- serialization problems */
- GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
- /* Always report on hard error as well to enable diagnostics */
- GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- phase_end (gorc,
- TALER_MHD_reply_with_error (gorc->sc.con,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_FETCH_FAILED,
- "order"));
- return;
- }
- if (gorc->order_only &&
- (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) )
- {
- phase_end (gorc,
- TALER_MHD_reply_with_error (gorc->sc.con,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN,
- hc->infix));
- return;
- }
- if (gorc->order_only)
- {
- gorc->contract_terms = ct;
- }
- else if (NULL != ct)
- {
- json_decref (ct);
- }
+ &gorc->contract_terms);
+ }
+ if (0 > qs)
+ {
+ /* single, read-only SQL statements should never cause
+ serialization problems */
+ GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
+ /* Always report on hard error as well to enable diagnostics */
+ GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
+ phase_end (gorc,
+ TALER_MHD_reply_with_error (gorc->sc.con,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "order"));
+ return;
+ }
+ if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
+ {
+ phase_end (gorc,
+ TALER_MHD_reply_with_error (gorc->sc.con,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN,
+ hc->infix));
+ return;
}
gorc->phase++;
}