gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: implement #9096


From: gnunet
Subject: [taler-exchange] branch master updated: implement #9096
Date: Thu, 05 Sep 2024 14:10:14 +0200

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new 2606fbc7a implement #9096
2606fbc7a is described below

commit 2606fbc7a78a1b58418a460b71495fe8fa1b2e00
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Sep 5 14:10:10 2024 +0200

    implement #9096
---
 src/exchange/taler-exchange-httpd_kyc-check.c    | 33 +++++++++++++-
 src/exchangedb/exchange_do_kycauth_in_insert.sql | 10 ++++-
 src/exchangedb/pg_kycauth_in_insert.c            | 55 +++++++++++++++---------
 3 files changed, 75 insertions(+), 23 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_kyc-check.c 
b/src/exchange/taler-exchange-httpd_kyc-check.c
index 8a7b5f1d3..aca07cdee 100644
--- a/src/exchange/taler-exchange-httpd_kyc-check.c
+++ b/src/exchange/taler-exchange-httpd_kyc-check.c
@@ -82,6 +82,12 @@ struct KycPoller
    */
   bool suspended;
 
+  /**
+   * True if we are long polling for a KYC authorization
+   * wire transfer.
+   */
+  bool await_auth;
+
 };
 
 
@@ -223,7 +229,15 @@ TEH_handler_kyc_check (
       sig_required);
     TALER_MHD_parse_request_timeout (rc->connection,
                                      &kyp->timeout);
+    {
+      enum TALER_EXCHANGE_YesNoAll yna;
 
+      TALER_MHD_parse_request_yna (rc->connection,
+                                   "await_auth",
+                                   TALER_EXCHANGE_YNA_NO,
+                                   &yna);
+      kyc->await_auth = (TALER_EXCHANGE_YNA_YES == yna);
+    }
     /* long polling needed? */
     if (GNUNET_TIME_absolute_is_future (kyp->timeout))
     {
@@ -281,7 +295,23 @@ TEH_handler_kyc_check (
     }
     if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
     {
-      GNUNET_break_op (0);
+      /* account unknown */
+      if ( (kyp->await_auth) &&
+           (GNUNET_TIME_absolute_is_future (kyp->timeout)) )
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                    "Suspending HTTP request on timeout (%s) now...\n",
+                    GNUNET_TIME_relative2s (GNUNET_TIME_absolute_get_remaining 
(
+                                              kyp->timeout),
+                                            true));
+        GNUNET_assert (NULL != kyp->eh);
+        kyp->suspended = true;
+        GNUNET_CONTAINER_DLL_insert (kyp_head,
+                                     kyp_tail,
+                                     kyp);
+        MHD_suspend_connection (kyp->connection);
+        return MHD_YES;
+      }
       return TALER_MHD_reply_with_error (
         rc->connection,
         MHD_HTTP_NOT_FOUND,
@@ -335,6 +365,7 @@ TEH_handler_kyc_check (
   jrules = NULL;
 
   if ( (kyc_required) &&
+       (! kyp->await_auth) &&
        GNUNET_TIME_absolute_is_future (kyp->timeout))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
diff --git a/src/exchangedb/exchange_do_kycauth_in_insert.sql 
b/src/exchangedb/exchange_do_kycauth_in_insert.sql
index 63d5cad3b..206c80f1a 100644
--- a/src/exchangedb/exchange_do_kycauth_in_insert.sql
+++ b/src/exchangedb/exchange_do_kycauth_in_insert.sql
@@ -15,14 +15,16 @@
 --
 
 
-CREATE OR REPLACE PROCEDURE exchange_do_kycauth_in_insert(
+DROP PROCEDURE IF EXISTS exchange_do_kycauth_in_insert;
+CREATE PROCEDURE exchange_do_kycauth_in_insert(
   IN in_account_pub BYTEA,
   IN in_wire_reference INT8,
   IN in_credit taler_amount,
   IN in_wire_source_h_payto BYTEA,
   IN in_payto_uri TEXT,
   IN in_exchange_account_name TEXT,
-  IN in_execution_date INT8)
+  IN in_execution_date INT8,
+  IN in_notify_s TEXT)
 LANGUAGE plpgsql
 AS $$
 BEGIN
@@ -66,4 +68,8 @@ BEGIN
       ,in_account_pub);
   END IF;
 
+  EXECUTE FORMAT (
+     'NOTIFY %s'
+    ,in_notify_s);
+
 END $$;
diff --git a/src/exchangedb/pg_kycauth_in_insert.c 
b/src/exchangedb/pg_kycauth_in_insert.c
index aafbe2acb..2f2ebcec9 100644
--- a/src/exchangedb/pg_kycauth_in_insert.c
+++ b/src/exchangedb/pg_kycauth_in_insert.c
@@ -38,27 +38,42 @@ TEH_PG_kycauth_in_insert (
 {
   struct PostgresClosure *pg = cls;
   struct TALER_PaytoHashP h_payto;
-  struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_auto_from_type (account_pub),
-    GNUNET_PQ_query_param_uint64 (&serial_id),
-    TALER_PQ_query_param_amount (pg->conn,
-                                 credit_amount),
-    GNUNET_PQ_query_param_auto_from_type (&h_payto),
-    GNUNET_PQ_query_param_string (debit_account_uri),
-    GNUNET_PQ_query_param_string (section_name),
-    GNUNET_PQ_query_param_timestamp (&execution_date),
-    GNUNET_PQ_query_param_end
-  };
 
-  PREPARE (pg,
-           "kycauth_in_insert",
-           "CALL"
-           " exchange_do_kycauth_in_insert"
-           " ($1,$2,$3,$4,$5,$6,$7);");
   TALER_payto_hash (debit_account_uri,
                     &h_payto);
-  return GNUNET_PQ_eval_prepared_non_select (
-    pg->conn,
-    "kycauth_in_insert",
-    params);
+
+  {
+    struct TALER_KycCompletedEventP rep = {
+      .header.size = htons (sizeof (rep)),
+      .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
+      .h_payto = h_payto
+    };
+    char *notify_s
+      = GNUNET_PQ_get_event_notify_channel (&rep.header);
+    struct GNUNET_PQ_QueryParam params[] = {
+      GNUNET_PQ_query_param_auto_from_type (account_pub),
+      GNUNET_PQ_query_param_uint64 (&serial_id),
+      TALER_PQ_query_param_amount (pg->conn,
+                                   credit_amount),
+      GNUNET_PQ_query_param_auto_from_type (&h_payto),
+      GNUNET_PQ_query_param_string (debit_account_uri),
+      GNUNET_PQ_query_param_string (section_name),
+      GNUNET_PQ_query_param_timestamp (&execution_date),
+      GNUNET_PQ_query_param_string (notify_s),
+      GNUNET_PQ_query_param_end
+    };
+    enum GNUNET_DB_QueryStatus qs;
+
+    PREPARE (pg,
+             "kycauth_in_insert",
+             "CALL"
+             " exchange_do_kycauth_in_insert"
+             " ($1,$2,$3,$4,$5,$6,$7,$8);");
+    qs = GNUNET_PQ_eval_prepared_non_select (
+      pg->conn,
+      "kycauth_in_insert",
+      params);
+    GNUNET_free (notify_s);
+    return qs;
+  }
 }

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