commit 9318ef6e853a277fd50531b71c065b22ea0adfc8
parent f1af21e4537dd59e31d532f9495a0bd7a0020ad0
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Fri, 31 Oct 2025 11:36:47 +0100
expand tokenfamily api for turnstile
Diffstat:
3 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-token-families.c b/src/backend/taler-merchant-httpd_private-get-token-families.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- (C) 2023 Taler Systems SA
+ (C) 2023, 2025 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -22,7 +22,6 @@
#include "taler-merchant-httpd_private-get-token-families.h"
-
/**
* Add token family details to our JSON array.
*
@@ -37,6 +36,8 @@ static void
add_token_family (void *cls,
const char *slug,
const char *name,
+ const char *description,
+ const json_t *description_i18n,
struct GNUNET_TIME_Timestamp valid_after,
struct GNUNET_TIME_Timestamp valid_before,
const char *kind)
@@ -44,14 +45,24 @@ add_token_family (void *cls,
json_t *pa = cls;
GNUNET_assert (0 ==
- json_array_append_new (
- pa,
- GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("slug", slug),
- GNUNET_JSON_pack_string ("name", name),
- GNUNET_JSON_pack_timestamp ("valid_after", valid_after),
- GNUNET_JSON_pack_timestamp ("valid_before", valid_before),
- GNUNET_JSON_pack_string ("kind", kind))));
+ json_array_append_new (
+ pa,
+ GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("slug",
+ slug),
+ GNUNET_JSON_pack_string ("name",
+ name),
+ GNUNET_JSON_pack_string ("description",
+ description),
+ GNUNET_JSON_pack_allow_null (
+ GNUNET_JSON_pack_object_incref ("description_i18n",
+ description_i18n)),
+ GNUNET_JSON_pack_timestamp ("valid_after",
+ valid_after),
+ GNUNET_JSON_pack_timestamp ("valid_before",
+ valid_before),
+ GNUNET_JSON_pack_string ("kind",
+ kind))));
}
@@ -80,8 +91,9 @@ TMH_private_get_tokenfamilies (const struct TMH_RequestHandler *rh,
}
return TALER_MHD_REPLY_JSON_PACK (connection,
MHD_HTTP_OK,
- GNUNET_JSON_pack_array_steal ("token_families",
- families));
+ GNUNET_JSON_pack_array_steal (
+ "token_families",
+ families));
}
diff --git a/src/backenddb/pg_lookup_token_families.c b/src/backenddb/pg_lookup_token_families.c
@@ -68,6 +68,8 @@ lookup_token_families_cb (void *cls,
{
char *slug;
char *name;
+ char *description;
+ json_t *description_i18n = NULL;
char *kind;
struct GNUNET_TIME_Timestamp valid_after;
struct GNUNET_TIME_Timestamp valid_before;
@@ -76,12 +78,18 @@ lookup_token_families_cb (void *cls,
&slug),
GNUNET_PQ_result_spec_string ("name",
&name),
+ GNUNET_PQ_result_spec_string ("description",
+ &description),
+ GNUNET_PQ_result_spec_allow_null (
+ TALER_PQ_result_spec_json ("description_i18n",
+ &description_i18n),
+ NULL),
GNUNET_PQ_result_spec_timestamp ("valid_after",
&valid_after),
GNUNET_PQ_result_spec_timestamp ("valid_before",
&valid_before),
GNUNET_PQ_result_spec_string ("kind",
- &kind),
+ &kind),
GNUNET_PQ_result_spec_end
};
@@ -131,6 +139,8 @@ TMH_PG_lookup_token_families (void *cls,
"SELECT"
" slug"
",name"
+ ",description"
+ ",description_i18n"
",valid_after"
",valid_before"
",kind"
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
@@ -1205,6 +1205,8 @@ enum TALER_MERCHANTDB_TokenFamilyKind
* @param cls a `json_t *` JSON array to build
* @param slug slug of the token family
* @param name name of the token family
+ * @param description description of the token family
+ * @param description_i18n Internationalized token family description.
* @param start_time start time of the token family's validity period
* @param expiration end time of the token family's validity period
* @param kind kind of the token family
@@ -1214,6 +1216,8 @@ typedef void
void *cls,
const char *slug,
const char *name,
+ const char *description,
+ const json_t *description_i18n,
struct GNUNET_TIME_Timestamp start_time,
struct GNUNET_TIME_Timestamp expiration,
const char *kind);