gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated: Elaborating /track/


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: Elaborating /track/transfer response for cached responses as well.
Date: Mon, 13 Mar 2017 15:24:27 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 4187846  Elaborating /track/transfer response for cached responses as 
well.
4187846 is described below

commit 41878462c87141f2c0b782bcfd68e8c7ce30ce11
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 13 15:24:05 2017 +0100

    Elaborating /track/transfer response for cached responses
    as well.
---
 src/backend/taler-merchant-httpd_track-transfer.c | 38 ++++++++++++++---------
 src/lib/merchant_api_track_transfer.c             |  2 +-
 src/lib/test_merchant_api.c                       |  4 +++
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_track-transfer.c 
b/src/backend/taler-merchant-httpd_track-transfer.c
index ecd51bd..26cdff6 100644
--- a/src/backend/taler-merchant-httpd_track-transfer.c
+++ b/src/backend/taler-merchant-httpd_track-transfer.c
@@ -249,7 +249,8 @@ transform_response (const json_t *result)
   struct TALER_Amount iter_fee;
   struct Entry *current_entry;
 
-  /* TODO/FIXME Free the values in hashmap! */
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Transforming /track/transfer response.\n");
 
   struct GNUNET_JSON_Specification spec[] = {
     TALER_JSON_spec_amount ("deposit_value", &iter_value),
@@ -320,18 +321,10 @@ transform_response (const json_t *result)
 
   result_mod = json_copy ((struct json_t *) result);
   json_object_del (result_mod, "deposits");
-  json_object_set (result_mod, "deposits", deposits_response);
-
-  /**
-   * Missing actions:
-   *
-   * 1) Take the sums in the map and convert them into
-   *    appropriate JSON (x).
-   * 2) Translate h_proposal_data into order_id and place
-   *    it somewhere in the response.
-   * 3) Return result (x).
-   */
-
+  json_object_set (result_mod, "deposits_sums", deposits_response);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Returning: '%s'.\n",
+              json_dumps (result_mod, JSON_INDENT (1)));
   goto cleanup;
 
   cleanup:
@@ -340,6 +333,9 @@ transform_response (const json_t *result)
                                            NULL);  
     GNUNET_JSON_parse_free (spec);
     GNUNET_CONTAINER_multihashmap_destroy (map);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Returning: '%s'.\n",
+                json_dumps (result_mod, JSON_INDENT (1)));
     return result_mod;
 }
 
@@ -589,7 +585,10 @@ wire_transfer_cb (void *cls,
     }
   }
   rctx->original_response = NULL;
-  /* FIXME, implement response transformator. Handle error as well. */
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "About to call tracks transformator.\n");
+
   if (NULL == (jresponse = transform_response (json)))
   {
     resume_track_transfer_with_response
@@ -682,9 +681,18 @@ proof_cb (void *cls,
           const json_t *proof)
 {
   struct TrackTransferContext *rctx = cls;
+  json_t *transformed_response;
+
+  if (NULL == (transformed_response = transform_response (proof)))
+  {
+    rctx->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+    rctx->response = TMH_RESPONSE_make_internal_error 
(TALER_EC_TRACK_TRANSFER_JSON_RESPONSE_ERROR,
+                                                       "Fail to elaborate 
response.");
+    return;
+  }
 
   rctx->response_code = MHD_HTTP_OK;
-  rctx->response = TMH_RESPONSE_make_json (proof);
+  rctx->response = TMH_RESPONSE_make_json (transformed_response);
 }
 
 
diff --git a/src/lib/merchant_api_track_transfer.c 
b/src/lib/merchant_api_track_transfer.c
index f9a8709..e34730f 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -95,7 +95,7 @@ check_track_transfer_response_ok (struct 
TALER_MERCHANT_TrackTransferHandle *wdh
     TALER_JSON_spec_amount ("total", &total_amount),
     GNUNET_JSON_spec_fixed_auto ("merchant_pub", &merchant_pub),
     GNUNET_JSON_spec_fixed_auto ("H_wire", &h_wire),
-    GNUNET_JSON_spec_json ("deposits", &deposits),
+    GNUNET_JSON_spec_json ("deposits_sums", &deposits),
     GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub),
     GNUNET_JSON_spec_end()
   };
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index e59d542..3688cd7 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1205,6 +1205,10 @@ track_transfer_cb (void *cls,
   struct InterpreterState *is = cls;
   struct Command *cmd = &is->commands[is->ip];
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Tracked transfers: '%s'.\n",
+              json_dumps (json, JSON_INDENT (1)));
+
   cmd->details.track_transfer.tdo = NULL;
   if (cmd->expected_response_code != http_status)
   {

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]