gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/02: modified reducer


From: gnunet
Subject: [taler-anastasis] 02/02: modified reducer
Date: Thu, 17 Sep 2020 15:29:40 +0200

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit 2545fa5fe9d70486c54c216ea9deb34ce76c7432
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Thu Sep 17 15:28:44 2020 +0200

    modified reducer
---
 src/lib/anastasis_api_backup_redux.c | 125 +++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 6b6f05e..d6331d1 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -362,6 +362,111 @@ enter_user_attributes (const json_t *state,
 }
 
 
+static void
+edit_user_attributes (const json_t *state,
+                      const json_t *arguments,
+                      ANASTASIS_ActionCallback cb,
+                      void *cb_cls)
+{
+  json_t *new_state;
+  json_t *attributes = json_object_get (arguments, "identity");
+
+  if (NULL == state)
+  {
+    GNUNET_break (0);
+    cb (cb_cls,
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
+  }
+  if (NULL == attributes)
+  {
+    GNUNET_break (0);
+    cb (cb_cls,
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
+  }
+
+  new_state = json_deep_copy (state);
+  if (NULL == new_state)
+  {
+    GNUNET_break (0);
+    cb (cb_cls,
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
+  }
+
+
+  json_object_set_new (new_state,
+                       "identity_attributes",
+                       attributes);
+
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      new_state);
+  json_decref (new_state);
+}
+
+
+static void
+change_country (const json_t *state,
+                const json_t *arguments,
+                ANASTASIS_ActionCallback cb,
+                void *cb_cls)
+{
+  json_t *new_state;
+  json_t *root;
+  json_t *country = json_object_get (arguments, "country_code");
+
+  if (NULL == state)
+  {
+    GNUNET_break (0);
+    cb (cb_cls,
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
+  }
+  if (NULL == country)
+  {
+    GNUNET_break (0);
+    cb (cb_cls,
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
+  }
+  if (GNUNET_SYSERR ==
+      redux_id_attr_init (json_string_value (country)))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
+  new_state = json_deep_copy (state);
+  if (NULL == new_state)
+  {
+    GNUNET_break (0);
+    cb (cb_cls,
+        ANASTASIS_EC_INVALID, // FIXME: Define correct error code
+        NULL);
+  }
+  root = json_object_get (redux_id_attr, "required_attributes");
+
+
+  json_object_set (new_state,
+                   "backup-state",
+                   json_string ("ReduxCountrySelectedState"));
+
+  json_object_set_new (new_state,
+                       "selected_country",
+                       country);
+
+  json_object_set_new (new_state,
+                       "required_attributes",
+                       root);
+
+  cb (cb_cls,
+      ANASTASIS_EC_NONE,
+      new_state);
+  json_decref (new_state);
+}
+
+
 static void
 add_authentication (const json_t *state,
                     const json_t *arguments,
@@ -423,16 +528,36 @@ ANASTASIS_backup_action (const json_t *state,
       "entering_user_attributes",
       &enter_user_attributes
     },
+    {
+      "ReduxCountrySelectedState",
+      "changing_country",
+      &change_country
+    },
     {
       "ReduxUserAttributesAddedState",
       "adding_authentication",
       &add_authentication
     },
+    {
+      "ReduxUserAttributesAddedState",
+      "editing_user_attributes",
+      &edit_user_attributes
+    },
+    {
+      "ReduxUserAttributesAddedState",
+      "changing_country",
+      &change_country
+    },
     {
       "ReduxAuthenticationAddedState",
       "adding_policy",
       &add_policy
     },
+    {
+      "ReduxAuthenticationAddedState",
+      "editing_user_attributes",
+      &edit_user_attributes
+    },
     { NULL, NULL, NULL }
   };
   const char *s = json_string_value (json_object_get (state,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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