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 (0b5bb42 -> a1a5179)


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated (0b5bb42 -> a1a5179)
Date: Tue, 16 Jan 2018 14:47:41 +0100

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

dold pushed a change to branch master
in repository merchant.

    from 0b5bb42  fix leaks in /proposal handling
     new a0fffe7  convert amount from string in /proposal
     new a1a5179  use dot to separate default order_id for friendlier URLs

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/backend/taler-merchant-httpd_proposal.c | 33 ++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/backend/taler-merchant-httpd_proposal.c 
b/src/backend/taler-merchant-httpd_proposal.c
index 31e3fb3..82a38bd 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -122,6 +122,31 @@ json_parse_cleanup (struct TM_HandlerContext *hc)
 
 
 /**
+ * Convert an amount in a JSON object from the string amount format to the JSON
+ * amount format.  Does nothing if the field is missing or already a JSON
+ * object.
+ *
+ * @param json json with the amount to convert
+ * @param field_name name of the field to convert
+ * @returns #GNUNET_OK on success, #GNUNET_SYSERR on invalid format
+ */
+static int
+convert_amount (json_t *json, char *field_name)
+{
+  if (! json_is_string (json_object_get (json, field_name)))
+    return GNUNET_OK;
+  const char *amount_str = json_string_value (json_object_get (json, 
field_name));
+  GNUNET_assert (NULL != amount_str);
+  struct TALER_Amount amount;
+  if (GNUNET_OK != TALER_string_to_amount (amount_str, &amount))
+    return GNUNET_SYSERR;
+  json_object_del (json, field_name);
+  json_object_set_new (json, field_name, TALER_JSON_from_amount (&amount));
+  return GNUNET_OK;
+}
+
+
+/**
  * Transform an order into a proposal and store it in the database.
  * Write the resulting proposal or an error message ot a MHD connection
  *
@@ -178,7 +203,7 @@ proposal_put (struct MHD_Connection *connection,
     }
     off = strftime (buf,
                     sizeof (buf),
-                    "%H:%M:%S",
+                    "%H.%M.%S",
                     tm_info);
     snprintf (buf + off,
              sizeof (buf) - off,
@@ -190,6 +215,12 @@ proposal_put (struct MHD_Connection *connection,
                          json_string (buf));
   }
 
+  if (GNUNET_OK != convert_amount (order, "amount"))
+    return TMH_RESPONSE_reply_arg_invalid (connection,
+                                           TALER_EC_PARAMETER_MALFORMED,
+                                           "amount");
+
+  /* Add timestamp if it doesn't exist */
   if (NULL == json_object_get (order,
                                "timestamp"))
   {

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



reply via email to

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