gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: add logic to notify other servic


From: gnunet
Subject: [taler-merchant] branch master updated: add logic to notify other services about KYC status changes
Date: Sun, 08 Sep 2024 09:52:57 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 985e44ce add logic to notify other services about KYC status changes
985e44ce is described below

commit 985e44ce78eaaf3f2076f87ca7f6481af5608b2e
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Sep 8 09:52:53 2024 +0200

    add logic to notify other services about KYC status changes
---
 src/backenddb/pg_account_kyc_set_status.c   | 11 ++++-
 src/backenddb/pg_account_kyc_set_status.sql |  6 +++
 src/include/taler_merchantdb_plugin.h       | 68 ++++++++++++++++++-----------
 src/testing/testing_api_cmd_depositcheck.c  |  1 +
 src/testing/testing_api_cmd_pay_order.c     | 63 ++++++++++++++------------
 src/testing/testing_api_cmd_tme.c           |  1 +
 src/testing/testing_api_cmd_webhook.c       |  1 +
 7 files changed, 97 insertions(+), 54 deletions(-)

diff --git a/src/backenddb/pg_account_kyc_set_status.c 
b/src/backenddb/pg_account_kyc_set_status.c
index c4e8bd97..ecd63fb3 100644
--- a/src/backenddb/pg_account_kyc_set_status.c
+++ b/src/backenddb/pg_account_kyc_set_status.c
@@ -42,6 +42,13 @@ TMH_PG_account_kyc_set_status (
   bool kyc_ok)
 {
   struct PostgresClosure *pg = cls;
+  struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP ev = {
+    .header.size = htons (sizeof (ev)),
+    .header.type = htons (TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED),
+    .h_wire = *h_wire
+  };
+  char *notify_s
+    = GNUNET_PQ_get_event_notify_channel (&ev.header);
   uint32_t http_status32 = (uint32_t) exchange_http_status;
   uint32_t ec_code32 = (uint32_t) exchange_ec_code;
   struct GNUNET_PQ_QueryParam params[] = {
@@ -59,6 +66,7 @@ TMH_PG_account_kyc_set_status (
     : GNUNET_PQ_query_param_null (),
     GNUNET_PQ_query_param_bool (in_aml_review),
     GNUNET_PQ_query_param_bool (kyc_ok),
+    GNUNET_PQ_query_param_string (notify_s),
     GNUNET_PQ_query_param_end
   };
   bool no_instance;
@@ -79,12 +87,13 @@ TMH_PG_account_kyc_set_status (
            "  out_no_instance AS no_instance"
            " ,out_no_account AS no_account"
            " FROM merchant_do_account_kyc_set_status"
-           "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);");
+           "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);");
   qs = GNUNET_PQ_eval_prepared_singleton_select (
     pg->conn,
     "account_kyc_set_status",
     params,
     rs);
+  GNUNET_free (notify_s);
   if (qs <= 0)
   {
     GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
diff --git a/src/backenddb/pg_account_kyc_set_status.sql 
b/src/backenddb/pg_account_kyc_set_status.sql
index ce86a764..2d752167 100644
--- a/src/backenddb/pg_account_kyc_set_status.sql
+++ b/src/backenddb/pg_account_kyc_set_status.sql
@@ -28,6 +28,7 @@ CREATE FUNCTION merchant_do_account_kyc_set_status (
   IN in_jlimits TEXT,
   IN in_aml_active BOOL,
   IN in_kyc_ok BOOL,
+  IN in_notify_str TEXT,
   OUT out_no_instance BOOL,
   OUT out_no_account BOOL)
 LANGUAGE plpgsql
@@ -100,5 +101,10 @@ THEN
     ,in_access_token);
 END IF;
 
+EXECUTE FORMAT (
+   'NOTIFY %s'
+  ,in_notify_str);
+
+
 -- Success!
 END $$;
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index 00fe71fe..d88a93df 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -77,6 +77,19 @@ struct TALER_MerchantAuthenticationSaltP
 };
 
 
+struct TALER_MERCHANTDB_MerchantKycStatusChangeEventP
+{
+  /**
+   * Type is TALER_DBEVENT_MERCHANT_EXCHANGE_KYC_STATUS_CHANGED.
+   */
+  struct GNUNET_DB_EventHeaderP header;
+
+  /**
+   * Salted hash of the affected account.
+   */
+  struct TALER_MerchantWireHashP h_wire;
+};
+
 GNUNET_NETWORK_STRUCT_END
 
 /**
@@ -282,9 +295,10 @@ typedef void
  * @param product_id ID of the product
  */
 typedef void
-(*TALER_MERCHANTDB_ProductsCallback)(void *cls,
-                                     uint64_t product_serial,
-                                     const char *product_id);
+(*TALER_MERCHANTDB_ProductsCallback)(
+  void *cls,
+  uint64_t product_serial,
+  const char *product_id);
 
 
 /**
@@ -390,9 +404,10 @@ typedef void
  * @param template_description description of the template
  */
 typedef void
-(*TALER_MERCHANTDB_TemplatesCallback)(void *cls,
-                                      const char *template_id,
-                                      const char *template_description);
+(*TALER_MERCHANTDB_TemplatesCallback)(
+  void *cls,
+  const char *template_id,
+  const char *template_description);
 
 
 /**
@@ -403,9 +418,10 @@ typedef void
  * @param otp_description description of the OTP device
  */
 typedef void
-(*TALER_MERCHANTDB_OtpDeviceCallback)(void *cls,
-                                      const char *otp_id,
-                                      const char *otp_description);
+(*TALER_MERCHANTDB_OtpDeviceCallback)(
+  void *cls,
+  const char *otp_id,
+  const char *otp_description);
 
 
 /**
@@ -595,13 +611,14 @@ struct TALER_MERCHANTDB_WebhookDetails
  * @param body_template template for the body of the webhook
  */
 typedef void
-(*TALER_MERCHANTDB_WebhookDetailCallback)(void *cls,
-                                          uint64_t webhook_serial,
-                                          const char *event_type,
-                                          const char *url,
-                                          const char *http_method,
-                                          const char *header_template,
-                                          const char *body_template);
+(*TALER_MERCHANTDB_WebhookDetailCallback)(
+  void *cls,
+  uint64_t webhook_serial,
+  const char *event_type,
+  const char *url,
+  const char *http_method,
+  const char *header_template,
+  const char *body_template);
 
 
 /**
@@ -617,15 +634,16 @@ typedef void
  * @param body of the webhook
  */
 typedef void
-(*TALER_MERCHANTDB_PendingWebhooksCallback)(void *cls,
-                                            uint64_t webhook_pending_serial,
-                                            struct GNUNET_TIME_Absolute
-                                            next_attempt,
-                                            uint32_t retries,
-                                            const char *url,
-                                            const char *http_method,
-                                            const char *header,
-                                            const char *body);
+(*TALER_MERCHANTDB_PendingWebhooksCallback)(
+  void *cls,
+  uint64_t webhook_pending_serial,
+  struct GNUNET_TIME_Absolute
+  next_attempt,
+  uint32_t retries,
+  const char *url,
+  const char *http_method,
+  const char *header,
+  const char *body);
 
 
 /**
diff --git a/src/testing/testing_api_cmd_depositcheck.c 
b/src/testing/testing_api_cmd_depositcheck.c
index ad033d2e..6d1aa1e2 100644
--- a/src/testing/testing_api_cmd_depositcheck.c
+++ b/src/testing/testing_api_cmd_depositcheck.c
@@ -27,6 +27,7 @@
 #include <gnunet/gnunet_curl_lib.h>
 #include "taler/taler_signatures.h"
 #include "taler/taler_testing_lib.h"
+#include "taler/taler_merchant_testing_lib.h"
 
 
 /**
diff --git a/src/testing/testing_api_cmd_pay_order.c 
b/src/testing/testing_api_cmd_pay_order.c
index 97d0b66a..e9a893e3 100644
--- a/src/testing/testing_api_cmd_pay_order.c
+++ b/src/testing/testing_api_cmd_pay_order.c
@@ -156,6 +156,11 @@ find_token_public_key (const json_t *token_families,
 {
   const json_t *tf = json_object_get (token_families, slug);
   const json_t *keys;
+  struct GNUNET_JSON_Specification spec[] = {
+    GNUNET_JSON_spec_array_const ("keys",
+                                  &keys),
+    GNUNET_JSON_spec_end ()
+  };
 
   if (NULL == tf)
   {
@@ -164,13 +169,6 @@ find_token_public_key (const json_t *token_families,
                 slug);
     return GNUNET_SYSERR;
   }
-
-  struct GNUNET_JSON_Specification spec[] = {
-    GNUNET_JSON_spec_array_const ("keys",
-                                  &keys),
-    GNUNET_JSON_spec_end ()
-  };
-
   if (GNUNET_OK !=
       GNUNET_JSON_parse (tf,
                          spec,
@@ -191,7 +189,8 @@ find_token_public_key (const json_t *token_families,
     {
       int64_t cipher;
       struct GNUNET_TIME_Timestamp ivalid_after;
-      struct GNUNET_CRYPTO_BlindSignPublicKey *issue_pub = GNUNET_new (struct 
GNUNET_CRYPTO_BlindSignPublicKey);
+      struct GNUNET_CRYPTO_BlindSignPublicKey *issue_pub = GNUNET_new (struct
+                                                                       
GNUNET_CRYPTO_BlindSignPublicKey);
       const char *error_name;
       unsigned int error_line;
       struct GNUNET_JSON_Specification ispec[] = {
@@ -205,7 +204,7 @@ find_token_public_key (const json_t *token_families,
                                 &cipher),
         GNUNET_JSON_spec_timestamp ("valid_after",
                                     &ivalid_after),
-        GNUNET_JSON_spec_end()
+        GNUNET_JSON_spec_end ()
       };
 
       if (GNUNET_OK !=
@@ -222,7 +221,8 @@ find_token_public_key (const json_t *token_families,
         return GNUNET_SYSERR;
       }
 
-      switch (cipher) {
+      switch (cipher)
+      {
       case GNUNET_CRYPTO_BSA_RSA:
         issue_pub->cipher = GNUNET_CRYPTO_BSA_RSA;
         break;
@@ -237,7 +237,7 @@ find_token_public_key (const json_t *token_families,
       }
 
       /* Compare valid_after to make sure it matches. */
-      if (GNUNET_TIME_timestamp_cmp(valid_after, !=, ivalid_after))
+      if (GNUNET_TIME_timestamp_cmp (valid_after, !=, ivalid_after))
       {
         continue;
       }
@@ -249,7 +249,7 @@ find_token_public_key (const json_t *token_families,
 
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
               "Key with valid_after '%s' for token family '%s' not found\n",
-              GNUNET_TIME_timestamp2s(valid_after),
+              GNUNET_TIME_timestamp2s (valid_after),
               slug);
   return GNUNET_SYSERR;
 }
@@ -355,7 +355,8 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc,
       GNUNET_assert (GNUNET_OK ==
                      TALER_TESTING_get_trait_h_age_commitment (coin_cmd,
                                                                0,
-                                                               
&h_age_commitment));
+                                                               
&h_age_commitment
+                                                               ));
       icoin->coin_priv = *coin_priv;
       icoin->denom_pub = denom_pub->key;
       icoin->denom_sig = *denom_sig;
@@ -469,6 +470,7 @@ build_tokens (struct TALER_MERCHANT_UseToken **tokens,
   return GNUNET_OK;
 }
 
+
 /**
  * Function called with the result of a /pay operation.
  * Checks whether the merchant signature is valid and the
@@ -654,7 +656,7 @@ pay_run (void *cls,
                                   &max_fee),
       GNUNET_JSON_spec_mark_optional (
         GNUNET_JSON_spec_object_const ("token_families",
-                                      &token_families),
+                                       &token_families),
         NULL),
       GNUNET_JSON_spec_mark_optional (
         GNUNET_JSON_spec_array_const ("choices",
@@ -777,23 +779,23 @@ pay_run (void *cls,
 
       struct GNUNET_JSON_Specification ispec[] = {
         GNUNET_JSON_spec_string ("kind",
-                                  &kind),
+                                 &kind),
         GNUNET_JSON_spec_string ("token_family_slug",
-                                  &slug),
+                                 &slug),
         GNUNET_JSON_spec_timestamp ("valid_after",
                                     &valid_after),
         GNUNET_JSON_spec_mark_optional (
           GNUNET_JSON_spec_uint32 ("count",
-                                    &count),
+                                   &count),
           NULL),
-        GNUNET_JSON_spec_end()
+        GNUNET_JSON_spec_end ()
       };
 
       if (GNUNET_OK !=
           GNUNET_JSON_parse (output,
-                            ispec,
-                            &ierror_name,
-                            &ierror_line))
+                             ispec,
+                             &ierror_name,
+                             &ierror_line))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                     "Parser failed on %s:%u for input `%s'\n",
@@ -804,7 +806,7 @@ pay_run (void *cls,
         TALER_TESTING_FAIL (is);
       }
 
-      if (0 != strcmp("token", kind))
+      if (0 != strcmp ("token", kind))
       {
         continue;
       }
@@ -816,7 +818,7 @@ pay_run (void *cls,
       for (unsigned int k = 0; k < count; k++)
       {
         struct TALER_MERCHANT_PrivateTokenDetails *details =
-              &ps->issued_tokens[ps->num_issued_tokens - count + k];
+          &ps->issued_tokens[ps->num_issued_tokens - count + k];
 
         if (GNUNET_OK != find_token_public_key (token_families,
                                                 slug,
@@ -827,7 +829,8 @@ pay_run (void *cls,
         }
 
         /* Only RSA is supported for now. */
-        GNUNET_assert (GNUNET_CRYPTO_BSA_RSA == 
details->issue_pub.public_key->cipher);
+        GNUNET_assert (GNUNET_CRYPTO_BSA_RSA == details->issue_pub.public_key->
+                       cipher);
 
         TALER_token_blind_input_copy (&details->blinding_inputs,
                                       TALER_token_blind_input_rsa_singleton 
());
@@ -866,7 +869,8 @@ pay_run (void *cls,
                      ps->num_issued_tokens);
   for (unsigned int i = 0; i<len_output_tokens; i++)
   {
-    output_tokens[i].envelope.blinded_pub = 
ps->issued_tokens[i].envelope.blinded_pub;
+    output_tokens[i].envelope.blinded_pub = ps->issued_tokens[i].envelope.
+                                            blinded_pub;
   }
 
   if (GNUNET_OK !=
@@ -1005,11 +1009,14 @@ pay_traits (void *cls,
         TALER_TESTING_make_trait_otp_key (ps->pos_key),
         TALER_TESTING_make_trait_otp_alg (&ps->pos_alg),
         TALER_TESTING_make_trait_token_priv (index,
-                                             
&ps->issued_tokens[index].token_priv),
+                                             &ps->issued_tokens[index].
+                                             token_priv),
         TALER_TESTING_make_trait_token_issue_pub (index,
-                                                  
&ps->issued_tokens[index].issue_pub),
+                                                  &ps->issued_tokens[index].
+                                                  issue_pub),
         TALER_TESTING_make_trait_token_issue_sig (index,
-                                                  
&ps->issued_tokens[index].issue_sig),
+                                                  &ps->issued_tokens[index].
+                                                  issue_sig),
         TALER_TESTING_trait_end ()
       };
 
diff --git a/src/testing/testing_api_cmd_tme.c 
b/src/testing/testing_api_cmd_tme.c
index 549fe182..e812ffba 100644
--- a/src/testing/testing_api_cmd_tme.c
+++ b/src/testing/testing_api_cmd_tme.c
@@ -26,6 +26,7 @@
 #include <gnunet/gnunet_curl_lib.h>
 #include "taler/taler_signatures.h"
 #include "taler/taler_testing_lib.h"
+#include "taler/taler_merchant_testing_lib.h"
 
 
 /**
diff --git a/src/testing/testing_api_cmd_webhook.c 
b/src/testing/testing_api_cmd_webhook.c
index 8c5df5b9..73e305e5 100644
--- a/src/testing/testing_api_cmd_webhook.c
+++ b/src/testing/testing_api_cmd_webhook.c
@@ -26,6 +26,7 @@
 #include <gnunet/gnunet_curl_lib.h>
 #include "taler/taler_signatures.h"
 #include "taler/taler_testing_lib.h"
+#include "taler/taler_merchant_testing_lib.h"
 
 
 /**

-- 
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]