summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-05-20 11:59:13 -0300
committerSebastian <sebasjm@gmail.com>2022-05-20 11:59:13 -0300
commiteb819195844f6c28d8dd393517f4486132f379c5 (patch)
tree4651e1d27465778611528ca7c4d258c4e6b02b04 /src/backend
parentbc602bc7c77c85fa48babe3997cfe389a59d0861 (diff)
downloadmerchant-eb819195844f6c28d8dd393517f4486132f379c5.tar.gz
merchant-eb819195844f6c28d8dd393517f4486132f379c5.tar.bz2
merchant-eb819195844f6c28d8dd393517f4486132f379c5.zip
add email, site and logo for instances
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/taler-merchant-httpd.c9
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID.c9
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances.c6
-rw-r--r--src/backend/taler-merchant-httpd_private-patch-instances-ID.c43
-rw-r--r--src/backend/taler-merchant-httpd_private-post-instances.c44
-rw-r--r--src/backend/taler-merchant-httpd_private-post-orders.c11
6 files changed, 121 insertions, 1 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;