diff options
-rw-r--r-- | src/auditor/taler-auditor-httpd.c | 17 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation-del.c | 17 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation-get.c | 64 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation.c | 3 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation.h | 3 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_mhd.c | 4 |
6 files changed, 86 insertions, 22 deletions
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 6cdd5b861..60b04c6dc 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -266,7 +266,7 @@ handle_mhd_request (void *cls, // arguments, and the url itself, and a terminator that is always null const char *args[argsnr + 1]; - memset(&args,0,sizeof (args)); + memset (&args,0,sizeof (args)); size_t ulen = strlen (url) + 1; char d[ulen]; @@ -277,21 +277,24 @@ handle_mhd_request (void *cls, url, ulen); - args[i++] = strtok_r(d, "/", &sp); + args[i++] = strtok_r (d, "/", &sp); while ( (NULL != args[i - 1]) && (i < argsnr) ) - args[i++] = strtok_r(NULL, "/", &sp); + { + args[i++] = strtok_r (NULL, "/", &sp); + } + printf ("args: %s, %s, %s\n", args[0], args[1], args[2]); // max length url could be - char argurl[strlen(url) + 2]; - strcpy(argurl,"/"); + char argurl[strlen (url) + 2]; + strcpy (argurl,"/"); if (args[0] != NULL) - strcat(argurl,args[0]); + strcat (argurl,args[0]); - printf ("reconstructed link: %s\n", argurl); + printf ("reconstructed link: %s\n", argurl); if ( (0 == strcasecmp (argurl, rh->url)) && diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c index 91e9688c4..96996a7de 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c @@ -36,9 +36,9 @@ TAH_DEPOSIT_CONFIRMATION_handler_delete (struct TAH_RequestHandler *rh, MHD_RESULT res; enum GNUNET_DB_QueryStatus qs; - uint64_t row_id = 0; + uint64_t row_id = atoi (args[1]); - printf("args in handler: %s\n",args[1]); + // printf ("args in handler: %s\n",args[1]); if (GNUNET_SYSERR == TAH_plugin->preflight (TAH_plugin->cls)) @@ -57,20 +57,19 @@ TAH_DEPOSIT_CONFIRMATION_handler_delete (struct TAH_RequestHandler *rh, if (0 > qs) { // goes in here if there was an error with the transaction - - TALER_LOG_WARNING ("xyz\n"); + GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); + TALER_LOG_WARNING ("Failed to handle DELETE /deposit-confirmation/ %s\n", + args[1]); return TALER_MHD_reply_with_error (connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_AUDITOR_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, + MHD_HTTP_NOT_FOUND, + TALER_EC_EXCHANGE_DEPOSITS_GET_NOT_FOUND, "exchange signature invalid"); } - - // on success? return TALER_MHD_REPLY_JSON_PACK (connection, - MHD_HTTP_OK, + MHD_HTTP_NO_CONTENT, GNUNET_JSON_pack_string ("status", "DEPOSIT_CONFIRMATION_OK")); diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c index 33e3c7db7..c51638b74 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c @@ -137,10 +137,70 @@ TAH_DEPOSIT_CONFIRMATION_handler_get (struct TAH_RequestHandler *rh, }
ja = json_array ();
GNUNET_break (NULL != ja);
- // TODO correct below
+
+ uint64_t row_id = 0;
+
+ struct TALER_AUDITORDB_DepositConfirmation dc = {
+ .exchange_timestamp = GNUNET_TIME_UNIT_ZERO_TS,
+ .refund_deadline = GNUNET_TIME_UNIT_ZERO_TS,
+ .wire_deadline = GNUNET_TIME_UNIT_ZERO_TS
+ };
+
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_uint64 ("row_id",
+ &row_id),
+/*
+ GNUNET_JSON_spec_timestamp("exchange_timestamp",
+ &dc.exchange_timestamp),
+ GNUNET_JSON_spec_timestamp("refund_deadline",
+ &dc.refund_deadline),
+ GNUNET_JSON_spec_timestamp("wire_deadline",
+ &dc.wire_deadline),
+
+ TALER_JSON_spec_amount("amount_without_fee",
+ TAH_currency,
+ &dc.total_without_fee),
+*/
+ GNUNET_JSON_spec_end ()
+ };
+
+
+ // read the input json
+ json_t *json_in;
+ {
+ enum GNUNET_GenericReturnValue res;
+
+ res = TALER_MHD_parse_post_json (connection,
+ connection_cls,
+ upload_data,
+ upload_data_size,
+ &json_in);
+ if (GNUNET_SYSERR == res)
+ return MHD_NO;
+ if ((GNUNET_NO == res) ||
+ (NULL == json_in))
+ return MHD_YES;
+ res = TALER_MHD_parse_json_data (connection,
+ json_in,
+ spec);
+ if (GNUNET_SYSERR == res)
+ {
+ json_decref (json_in);
+ return MHD_NO; /* hard failure */
+ }
+ if (GNUNET_NO == res)
+ {
+ json_decref (json_in);
+ return MHD_YES; /* failure */
+ }
+ }
+
+ printf ("row_id from json: %lu\n", row_id);
+
+
qs = TAH_plugin->get_deposit_confirmations (
TAH_plugin->cls,
- 0, /* FIXME: get from query parameters! */
+ row_id,
false, /* FIXME: get from query parameters! */
&add_deposit_confirmation,
ja);
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c index 8b449bf47..fd3d717e7 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c @@ -275,7 +275,8 @@ TAH_DEPOSIT_CONFIRMATION_handler ( struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size) + size_t *upload_data_size, + const char *const args[]) { struct TALER_AUDITORDB_DepositConfirmation dc = { .refund_deadline = GNUNET_TIME_UNIT_ZERO_TS diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.h b/src/auditor/taler-auditor-httpd_deposit-confirmation.h index 1226dda69..0663a987a 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation.h +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.h @@ -54,7 +54,8 @@ TAH_DEPOSIT_CONFIRMATION_handler (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size); + size_t *upload_data_size, + const char *const args[]); #endif diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index 0edbd303a..f150c6846 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -49,7 +49,7 @@ TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, void **connection_cls, const char *upload_data, size_t *upload_data_size, -const char *const args[]) + const char *const args[]) { size_t dlen; @@ -84,7 +84,7 @@ TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, void **connection_cls, const char *upload_data, size_t *upload_data_size, -const char *const args[]) + const char *const args[]) { (void) rh; (void) connection_cls; |