gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: add email, site and logo for ins


From: gnunet
Subject: [taler-merchant] branch master updated: add email, site and logo for instances
Date: Fri, 20 May 2022 17:00:24 +0200

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

sebasjm pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new eb819195 add email, site and logo for instances
eb819195 is described below

commit eb819195844f6c28d8dd393517f4486132f379c5
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Fri May 20 11:59:13 2022 -0300

    add email, site and logo for instances
---
 src/backend/taler-merchant-httpd.c                 |  9 +++++
 ...taler-merchant-httpd_private-get-instances-ID.c |  9 +++++
 .../taler-merchant-httpd_private-get-instances.c   |  6 +++
 ...ler-merchant-httpd_private-patch-instances-ID.c | 43 ++++++++++++++++++++
 .../taler-merchant-httpd_private-post-instances.c  | 44 +++++++++++++++++++++
 .../taler-merchant-httpd_private-post-orders.c     | 11 +++++-
 src/backenddb/{merchant-0002.sql => drop0002.sql}  | 15 +++++--
 src/backenddb/merchant-0002.sql                    | 14 ++++++-
 src/backenddb/plugin_merchantdb_postgres.c         | 46 +++++++++++++++++++++-
 src/include/taler_merchantdb_plugin.h              | 14 +++++++
 10 files changed, 203 insertions(+), 8 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index 2b375003..d4d8bc11 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -232,6 +232,9 @@ TMH_instance_decref (struct TMH_MerchantInstance *mi)
 
   GNUNET_free (mi->settings.id);
   GNUNET_free (mi->settings.name);
+  GNUNET_free (mi->settings.email);
+  GNUNET_free (mi->settings.website);
+  GNUNET_free (mi->settings.logo);
   json_decref (mi->settings.address);
   json_decref (mi->settings.jurisdiction);
   GNUNET_free (mi);
@@ -1542,6 +1545,12 @@ add_instance_cb (void *cls,
   mi->auth = *ias;
   mi->settings.id = GNUNET_strdup (mi->settings.id);
   mi->settings.name = GNUNET_strdup (mi->settings.name);
+  if (NULL != mi->settings.email)
+    mi->settings.email = GNUNET_strdup (mi->settings.email);
+  if (NULL != mi->settings.website)
+    mi->settings.website = GNUNET_strdup (mi->settings.website);
+  if (NULL != mi->settings.logo)
+    mi->settings.logo = GNUNET_strdup (mi->settings.logo);
   mi->settings.address = json_incref (mi->settings.address);
   mi->settings.jurisdiction = json_incref (mi->settings.jurisdiction);
   if (NULL != merchant_priv)
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID.c 
b/src/backend/taler-merchant-httpd_private-get-instances-ID.c
index 5087d637..5cc7764f 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances-ID.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID.c
@@ -73,6 +73,15 @@ get_instances_ID (struct TMH_MerchantInstance *mi,
                                   ja),
     GNUNET_JSON_pack_string ("name",
                              mi->settings.name),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("website",
+                               mi->settings.website)),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("email",
+                               mi->settings.email)),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("logo",
+                               mi->settings.logo)),
     GNUNET_JSON_pack_data_auto ("merchant_pub",
                                 &mi->merchant_pub),
     GNUNET_JSON_pack_object_incref ("address",
diff --git a/src/backend/taler-merchant-httpd_private-get-instances.c 
b/src/backend/taler-merchant-httpd_private-get-instances.c
index f802fe66..3eedcd83 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances.c
@@ -74,6 +74,12 @@ add_instance (void *cls,
                    GNUNET_JSON_PACK (
                      GNUNET_JSON_pack_string ("name",
                                               mi->settings.name),
+                     GNUNET_JSON_pack_allow_null (
+                       GNUNET_JSON_pack_string ("website",
+                                                mi->settings.website)),
+                     GNUNET_JSON_pack_allow_null (
+                       GNUNET_JSON_pack_string ("logo",
+                                                mi->settings.logo)),
                      GNUNET_JSON_pack_string ("id",
                                               mi->settings.id),
                      GNUNET_JSON_pack_data_auto ("merchant_pub",
diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c
index 727a641e..24f7c097 100644
--- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c
@@ -71,6 +71,18 @@ patch_instances_ID (struct TMH_MerchantInstance *mi,
                            &payto_uris),
     GNUNET_JSON_spec_string ("name",
                              &name),
+    GNUNET_JSON_spec_mark_optional(
+      GNUNET_JSON_spec_string ("website",
+                               (const char **) &is.website),
+      NULL),
+    GNUNET_JSON_spec_mark_optional(
+      GNUNET_JSON_spec_string ("email",
+                                (const char **) &is.email),
+      NULL),
+    GNUNET_JSON_spec_mark_optional(
+      GNUNET_JSON_spec_string ("logo",
+                                (const char **) &is.logo),
+      NULL),
     GNUNET_JSON_spec_json ("address",
                            &is.address),
     GNUNET_JSON_spec_json ("jurisdiction",
@@ -116,6 +128,16 @@ patch_instances_ID (struct TMH_MerchantInstance *mi,
                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
                                        "address");
   }
+  if ( (NULL != is.logo) &&
+       (! TMH_image_data_url_valid (is.logo)) )
+  {
+    GNUNET_break_op (0);
+    GNUNET_JSON_parse_free (spec);
+    return TALER_MHD_reply_with_error (connection,
+                                       MHD_HTTP_BAD_REQUEST,
+                                       TALER_EC_GENERIC_PARAMETER_MALFORMED,
+                                       "logo");
+  }
 
   if (! TMH_location_object_valid (is.jurisdiction))
   {
@@ -159,6 +181,18 @@ patch_instances_ID (struct TMH_MerchantInstance *mi,
     /* Check for equality of settings */
     if (! ( (0 == strcmp (mi->settings.name,
                           name)) &&
+            ((mi->settings.email == is.email) ||
+             (NULL != is.email && NULL != mi->settings.email &&
+              0 == strcmp (mi->settings.email,
+                            is.email))) &&
+            ((mi->settings.website == is.website) ||
+             (NULL != is.website && NULL != mi->settings.website &&
+              0 == strcmp (mi->settings.website,
+                            is.website))) &&
+            ((mi->settings.logo == is.logo) ||
+             (NULL != is.logo && NULL != mi->settings.logo &&
+              0 == strcmp (mi->settings.logo,
+                            is.logo))) &&
             (1 == json_equal (mi->settings.address,
                               is.address)) &&
             (1 == json_equal (mi->settings.jurisdiction,
@@ -351,6 +385,9 @@ giveup:
 
   /* Update our 'settings' */
   GNUNET_free (mi->settings.name);
+  GNUNET_free (mi->settings.email);
+  GNUNET_free (mi->settings.website);
+  GNUNET_free (mi->settings.logo);
   json_decref (mi->settings.address);
   json_decref (mi->settings.jurisdiction);
   is.id = mi->settings.id;
@@ -358,6 +395,12 @@ giveup:
   mi->settings.address = json_incref (mi->settings.address);
   mi->settings.jurisdiction = json_incref (mi->settings.jurisdiction);
   mi->settings.name = GNUNET_strdup (name);
+  if (NULL != is.email)
+    mi->settings.email = GNUNET_strdup (is.email);
+  if (NULL != is.website)
+    mi->settings.website = GNUNET_strdup (is.website);
+  if (NULL != is.logo)
+    mi->settings.logo = GNUNET_strdup (is.logo);
 
   /* Add 'new' wire methods to our list */
   {
diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c 
b/src/backend/taler-merchant-httpd_private-post-instances.c
index e760d8e5..58a93b27 100644
--- a/src/backend/taler-merchant-httpd_private-post-instances.c
+++ b/src/backend/taler-merchant-httpd_private-post-instances.c
@@ -123,6 +123,9 @@ free_mi (struct TMH_MerchantInstance *mi)
   }
   GNUNET_free (mi->settings.id);
   GNUNET_free (mi->settings.name);
+  GNUNET_free (mi->settings.website);
+  GNUNET_free (mi->settings.email);
+  GNUNET_free (mi->settings.logo);
   json_decref (mi->settings.address);
   json_decref (mi->settings.jurisdiction);
   GNUNET_free (mi);
@@ -156,6 +159,18 @@ TMH_private_post_instances (const struct 
TMH_RequestHandler *rh,
                              (const char **) &is.id),
     GNUNET_JSON_spec_string ("name",
                              (const char **) &is.name),
+    GNUNET_JSON_spec_mark_optional(
+      GNUNET_JSON_spec_string ("email",
+                               (const char **) &is.email),
+      NULL),
+    GNUNET_JSON_spec_mark_optional(
+      GNUNET_JSON_spec_string ("website",
+                               (const char **) &is.website),
+      NULL),
+    GNUNET_JSON_spec_mark_optional(
+      GNUNET_JSON_spec_string ("logo",
+                               (const char **) &is.logo),
+      NULL),
     GNUNET_JSON_spec_json ("auth",
                            &jauth),
     GNUNET_JSON_spec_json ("address",
@@ -251,6 +266,17 @@ TMH_private_post_instances (const struct 
TMH_RequestHandler *rh,
                                        "jurisdiction");
   }
 
+  if ( (NULL != is.logo) &&
+       (! TMH_image_data_url_valid (is.logo)) )
+  {
+    GNUNET_break_op (0);
+    GNUNET_JSON_parse_free (spec);
+    return TALER_MHD_reply_with_error (connection,
+                                       MHD_HTTP_BAD_REQUEST,
+                                       TALER_EC_GENERIC_PARAMETER_MALFORMED,
+                                       "logo");
+  }
+
   {
     /* Test if an instance of this id is known */
     struct TMH_MerchantInstance *mi;
@@ -271,6 +297,18 @@ TMH_private_post_instances (const struct 
TMH_RequestHandler *rh,
                          is.id)) &&
            (0 == strcmp (mi->settings.name,
                          is.name)) &&
+            ((mi->settings.email == is.email) ||
+             (NULL != is.email && NULL != mi->settings.email &&
+              0 == strcmp (mi->settings.email,
+                            is.email))) &&
+            ((mi->settings.website == is.website) ||
+             (NULL != is.website && NULL != mi->settings.website &&
+              0 == strcmp (mi->settings.website,
+                            is.website))) &&
+            ((mi->settings.logo == is.logo) ||
+             (NULL != is.logo && NULL != mi->settings.logo &&
+              0 == strcmp (mi->settings.logo,
+                            is.logo))) &&
            ( ( (NULL != auth_token) &&
                (GNUNET_OK ==
                 TMH_check_auth (auth_token,
@@ -370,6 +408,12 @@ TMH_private_post_instances (const struct 
TMH_RequestHandler *rh,
     mi->settings.jurisdiction = json_incref (mi->settings.jurisdiction);
     mi->settings.id = GNUNET_strdup (is.id);
     mi->settings.name = GNUNET_strdup (is.name);
+    if (NULL != is.email)
+      mi->settings.email = GNUNET_strdup (is.email);
+    if (NULL != is.website)
+      mi->settings.website = GNUNET_strdup (is.website);
+    if (NULL != is.logo)
+      mi->settings.logo = GNUNET_strdup (is.logo);
     mi->auth = ias;
     GNUNET_CRYPTO_eddsa_key_create (&mi->merchant_priv.eddsa_priv);
     GNUNET_CRYPTO_eddsa_key_get_public (&mi->merchant_priv.eddsa_priv,
diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c 
b/src/backend/taler-merchant-httpd_private-post-orders.c
index 4631a18c..efaaf5a7 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders.c
@@ -1004,7 +1004,16 @@ patch_order (struct MHD_Connection *connection,
   }
   jmerchant = GNUNET_JSON_PACK (
     GNUNET_JSON_pack_string ("name",
-                             settings->name));
+                             settings->name),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("website",
+                               settings->website)),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("email",
+                               settings->email)),
+    GNUNET_JSON_pack_allow_null (
+      GNUNET_JSON_pack_string ("logo",
+                               settings->logo)));
   GNUNET_assert (NULL != jmerchant);
   {
     json_t *loca;
diff --git a/src/backenddb/merchant-0002.sql b/src/backenddb/drop0002.sql
similarity index 75%
copy from src/backenddb/merchant-0002.sql
copy to src/backenddb/drop0002.sql
index 87ccd220..cfb6773c 100644
--- a/src/backenddb/merchant-0002.sql
+++ b/src/backenddb/drop0002.sql
@@ -1,6 +1,6 @@
 --
 -- This file is part of TALER
--- Copyright (C) 2021 Taler Systems SA
+-- Copyright (C) 2014--2021 Taler Systems SA
 --
 -- TALER is free software; you can redistribute it and/or modify it under the
 -- terms of the GNU General Public License as published by the Free Software
@@ -17,8 +17,15 @@
 -- Everything in one big transaction
 BEGIN;
 
--- Check patch versioning is in place.
--- SELECT _v.register_patch('merchant-0002', NULL, NULL);
+SELECT _v.unregister_patch('merchant-0002');
 
--- Complete transaction
+
+-- Drops for 0002.sql
+ALTER TABLE merchant_instances 
+  DROP COLUMN website,
+  DROP COLUMN email,
+  DROP COLUMN logo;
+
+
+-- And we're out of here...
 COMMIT;
diff --git a/src/backenddb/merchant-0002.sql b/src/backenddb/merchant-0002.sql
index 87ccd220..5eacaa0b 100644
--- a/src/backenddb/merchant-0002.sql
+++ b/src/backenddb/merchant-0002.sql
@@ -18,7 +18,19 @@
 BEGIN;
 
 -- Check patch versioning is in place.
--- SELECT _v.register_patch('merchant-0002', NULL, NULL);
+SELECT _v.register_patch('merchant-0002', NULL, NULL);
+
+ALTER TABLE merchant_instances
+  ADD COLUMN website VARCHAR,
+  ADD COLUMN email VARCHAR,
+  ADD COLUMN logo BYTEA;
+
+COMMENT ON COLUMN merchant_instances.website
+  IS 'merchant site URL';
+COMMENT ON COLUMN merchant_instances.email
+  IS 'email';
+COMMENT ON COLUMN merchant_instances.logo
+  IS 'data image url';
 
 -- Complete transaction
 COMMIT;
diff --git a/src/backenddb/plugin_merchantdb_postgres.c 
b/src/backenddb/plugin_merchantdb_postgres.c
index 8a86c2a0..87049d9e 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -579,6 +579,18 @@ lookup_instances_cb (void *cls,
                                            
&lic->is.default_wire_transfer_delay),
       GNUNET_PQ_result_spec_relative_time ("default_pay_delay",
                                            &lic->is.default_pay_delay),
+      GNUNET_PQ_result_spec_allow_null (
+        GNUNET_PQ_result_spec_string ("website",
+                                      &lic->is.website),
+        NULL),
+      GNUNET_PQ_result_spec_allow_null (
+        GNUNET_PQ_result_spec_string ("email",
+                                      &lic->is.email),
+        NULL),
+      GNUNET_PQ_result_spec_allow_null (
+        GNUNET_PQ_result_spec_string ("logo",
+                                      &lic->is.logo),
+        NULL),
       GNUNET_PQ_result_spec_end
     };
     struct GNUNET_PQ_QueryParam params[] = {
@@ -767,6 +779,15 @@ postgres_insert_instance (
     GNUNET_PQ_query_param_relative_time (
       &is->default_wire_transfer_delay),
     GNUNET_PQ_query_param_relative_time (&is->default_pay_delay),
+    (NULL == is->website)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (is->website),
+    (NULL == is->email)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (is->email),
+    (NULL == is->logo)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (is->logo),
     GNUNET_PQ_query_param_end
   };
   struct GNUNET_PQ_QueryParam params_priv[] = {
@@ -1107,6 +1128,15 @@ postgres_update_instance (void *cls,
     GNUNET_PQ_query_param_relative_time (
       &is->default_wire_transfer_delay),
     GNUNET_PQ_query_param_relative_time (&is->default_pay_delay),
+    (NULL == is->website)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (is->website),
+    (NULL == is->email)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (is->email),
+    (NULL == is->logo)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (is->logo),
     GNUNET_PQ_query_param_end
   };
 
@@ -6816,6 +6846,9 @@ postgres_connect (void *cls)
                             ",default_wire_fee_amortization"
                             ",default_wire_transfer_delay"
                             ",default_pay_delay"
+                            ",website"
+                            ",email"
+                            ",logo"
                             " FROM merchant_instances",
                             0),
     /* for postgres_lookup_instance() */
@@ -6836,6 +6869,9 @@ postgres_connect (void *cls)
                             ",default_wire_fee_amortization"
                             ",default_wire_transfer_delay"
                             ",default_pay_delay"
+                            ",website"
+                            ",email"
+                            ",logo"
                             " FROM merchant_instances"
                             " WHERE merchant_id=$1",
                             1),
@@ -6855,9 +6891,12 @@ postgres_connect (void *cls)
                             ",default_max_wire_fee_frac"
                             ",default_wire_fee_amortization"
                             ",default_wire_transfer_delay"
-                            ",default_pay_delay)"
+                            ",default_pay_delay"
+                            ",website"
+                            ",email"
+                            ",logo)"
                             "VALUES"
-                            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, 
$12, $13, $14)",
+                            "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, 
$12, $13, $14, $15, $16, $17)",
                             14),
     /* for postgres_insert_instance() */
     GNUNET_PQ_make_prepare ("insert_keys",
@@ -6945,6 +6984,9 @@ postgres_connect (void *cls)
                             ",default_wire_fee_amortization=$9"
                             ",default_wire_transfer_delay=$10"
                             ",default_pay_delay=$11"
+                            ",website=$12"
+                            ",email=$13"
+                            ",logo=$14"
                             " WHERE merchant_id = $1",
                             11),
     /* for postgres_update_instance_auth() */
diff --git a/src/include/taler_merchantdb_plugin.h 
b/src/include/taler_merchantdb_plugin.h
index adbea0a9..41fb0b59 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -136,6 +136,20 @@ struct TALER_MERCHANTDB_InstanceSettings
    */
   char *name;
 
+  /**
+   * merchant's site url
+   */
+  char *website;
+
+  /**
+   * email contact for customers
+   */
+  char *email;
+
+  /**
+   * merchant's logo data uri
+   */
+  char *logo;
   /**
    * Address of the business
    */

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