[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: Worked on policy handler
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: Worked on policy handler |
Date: |
Wed, 20 Nov 2019 13:27:37 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 8a9996d Worked on policy handler
8a9996d is described below
commit 8a9996d94918f306b82e8e35df1570438beabfb5
Author: Dennis Neufeld <address@hidden>
AuthorDate: Wed Nov 20 12:27:23 2019 +0000
Worked on policy handler
---
src/backend/anastasis-httpd_policy.c | 93 +++++++++++++++++++++++++++++-------
1 file changed, 77 insertions(+), 16 deletions(-)
diff --git a/src/backend/anastasis-httpd_policy.c
b/src/backend/anastasis-httpd_policy.c
index 080a4a5..457e0d7 100644
--- a/src/backend/anastasis-httpd_policy.c
+++ b/src/backend/anastasis-httpd_policy.c
@@ -23,6 +23,7 @@
#include "platform.h"
#include "anastasis-httpd.h"
#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_rest_lib.h>
#include "anastasis-httpd_responses.h"
/**
@@ -38,6 +39,8 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
{
struct ANASTASIS_AccountPubP accountPubP;
void *res_recovery_data;
+ size_t *res_recovery_data_size;
+
const char *version_s;
int ret;
@@ -61,7 +64,7 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
version_s = MHD_lookup_connection_value (connection,
MHD_GET_ARGUMENT_KIND,
"version");
- unsigned int version;
+ uint32_t version;
if (NULL != version_s)
{
@@ -76,30 +79,31 @@ AH_handler_policy_GET (struct MHD_Connection *connection,
}
db->get_recovery_document (db->cls,
&accountPubP,
- sizeof (res_recovery_data),
- &res_recovery_data,
- &version);
+ version,
+ res_recovery_data_size,
+ res_recovery_data);
+ if (NULL == res_recovery_data_size)
+ return TMH_RESPONSE_reply_internal_error(connection,
+ 42 /*FIXME*/,
+ "recovery data size not
available");
}
else
{
db->get_latest_recovery_document (db->cls,
- &accountPubP,
- sizeof (res_recovery_data),
- &res_recovery_data,
- &version);
+ &accountPubP,
+ res_recovery_data_size,
+ &res_recovery_data,
+ &version);
}
-
+
// BUILD reply
// binary reply
-
{
struct MHD_Response *response;
- void *binary = "test";
- size_t binary_size = 4;
-
- response = MHD_create_response_from_buffer (binary_size,
- binary,
+
+ response = MHD_create_response_from_buffer (sizeof (res_recovery_data),
+ res_recovery_data,
MHD_RESPMEM_MUST_FREE);
TMH_RESPONSE_add_global_headers (response);
GNUNET_break (MHD_YES ==
@@ -129,6 +133,63 @@ AH_handler_policy_POST (struct MHD_Connection *connection,
size_t *upload_data_size)
{
+ struct ANASTASIS_AccountPubP accountPubP;
+ void *recovery_data;
+ const char *paymentIdentifier_str;
+ const struct ANASTASIS_PaymentSecretP *paymentIdentifier;
+ unsigned int version;
+ int ret;
+
+ GNUNET_assert (0 == strncmp (url,
+ "/policy/",
+ strlen ("/policy/")));
+ {
+ const char *account;
+
+ account = &url[strlen ("/policy/")];
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_public_key_from_string (account,
+ strlen (account),
+ &accountPubP.pub))
+ {
+ return TMH_RESPONSE_reply_bad_request (connection,
+ 42 /*FIXME */,
+ "account public key malformed");
+ }
+
+ paymentIdentifier_str = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "Payment-Identifier");
+
+ memcpy (&paymentIdentifier,
+ paymentIdentifier_str,
+ strlen (paymentIdentifier_str) + 1);
+
+ db->store_recovery_document (db->cls,
+ &accountPubP,
+ recovery_data,
+ sizeof (recovery_data),
+ paymentIdentifier,
+ &version);
+
+ }
+
+ // BUILD reply
+ {
+ struct MHD_Response *response;
+
+ //FIXME: find correct create response
+ response = GNUNET_REST_create_response ("Irgendwas");
- return MHD_NO;
+ TMH_RESPONSE_add_global_headers (response);
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (response,
+ "Anastasis-Version",
+ version + ""));
+ ret = MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ response);
+ MHD_destroy_response (response);
+ }
+ return ret;
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: Worked on policy handler,
gnunet <=