merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit e03008ad962fae68116da0fd4556ed93e4ffd852
parent 0edb2ad9afbe76d2c738138278a94630878d20a0
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 29 Mar 2026 22:10:42 +0200

add missing filter on product_group for GET /private/products

Diffstat:
Msrc/backend/taler-merchant-httpd_get-private-products.c | 5+++++
Msrc/backenddb/pg_lookup_products.c | 6++++++
Msrc/backenddb/pg_lookup_products.h | 3+++
Msrc/backenddb/test_merchantdb.c | 1+
Msrc/include/taler/taler_merchantdb_plugin.h | 3+++
Msrc/lib/merchant_api_get-private-products.c | 4++--
6 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-private-products.c b/src/backend/taler-merchant-httpd_get-private-products.c @@ -95,6 +95,7 @@ TMH_private_get_products (const struct TMH_RequestHandler *rh, char *description_filter; int64_t limit; uint64_t offset; + uint64_t product_group_id_filter = 0; limit = 20; /* default */ TALER_MHD_parse_request_snumber (connection, @@ -107,6 +108,9 @@ TMH_private_get_products (const struct TMH_RequestHandler *rh, TALER_MHD_parse_request_number (connection, "offset", &offset); + TALER_MHD_parse_request_number (connection, + "product_group_filter", + &product_group_id_filter); category_filter = tr (MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "category_filter")); @@ -125,6 +129,7 @@ TMH_private_get_products (const struct TMH_RequestHandler *rh, category_filter, name_filter, description_filter, + product_group_id_filter, &add_product, pa); GNUNET_free (category_filter); diff --git a/src/backenddb/pg_lookup_products.c b/src/backenddb/pg_lookup_products.c @@ -99,6 +99,7 @@ TMH_PG_lookup_products (void *cls, const char *category_filter, const char *name_filter, const char *description_filter, + uint64_t product_group_id_filter, TALER_MERCHANTDB_ProductsCallback cb, void *cb_cls) { @@ -123,6 +124,7 @@ TMH_PG_lookup_products (void *cls, ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (description_filter), GNUNET_PQ_query_param_uint64 (&plimit), + GNUNET_PQ_query_param_uint64 (&product_group_id_filter), GNUNET_PQ_query_param_end }; enum GNUNET_DB_QueryStatus qs; @@ -146,6 +148,8 @@ TMH_PG_lookup_products (void *cls, " (SELECT category_serial" " FROM merchant_categories" " WHERE category_name LIKE LOWER($3)))) )" + " AND ( (0 = $7::INT8) OR" + " (product_group_serial = $7) )" " AND ( ($4::TEXT IS NULL) OR" " (product_name LIKE LOWER($4)) )" " AND ( ($5::TEXT IS NULL) OR" @@ -170,6 +174,8 @@ TMH_PG_lookup_products (void *cls, " (SELECT category_serial" " FROM merchant_categories" " WHERE category_name LIKE LOWER($3)))) )" + " AND ( (0 = $7::INT8) OR" + " (product_group_serial = $7) )" " AND ( ($4::TEXT IS NULL) OR" " (product_name LIKE LOWER($4)) )" " AND ( ($5::TEXT IS NULL) OR" diff --git a/src/backenddb/pg_lookup_products.h b/src/backenddb/pg_lookup_products.h @@ -54,6 +54,8 @@ * use "\%" and "\_" to exactly match "%" or "_". * We will always use case-insensitive searches, for case-sensitive * matching the client should filter the result set. + * @param product_group_id_filter only return products in where the + * product group ID matches the given ID, 0 to not filter * @param cb function to call on all products found * @param cb_cls closure for @a cb * @return database result code @@ -66,6 +68,7 @@ TMH_PG_lookup_products (void *cls, const char *category_filter, const char *name_filter, const char *description_filter, + uint64_t product_group_id_filter, TALER_MERCHANTDB_ProductsCallback cb, void *cb_cls); diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -1056,6 +1056,7 @@ test_lookup_products (const struct InstanceData *instance, NULL, NULL, NULL, + 0, &lookup_products_cb, &cls)) { diff --git a/src/include/taler/taler_merchantdb_plugin.h b/src/include/taler/taler_merchantdb_plugin.h @@ -2716,6 +2716,8 @@ struct TALER_MERCHANTDB_Plugin * use "\%" and "\_" to exactly match "%" or "_". * We will always use case-insensitive searches, for case-sensitive * matching the client should filter the result set. + * @param product_group_id_filter only return products in where the + * product group ID matches the given ID, 0 to not filter * @param cb function to call on all products found * @param cb_cls closure for @a cb * @return database result code @@ -2728,6 +2730,7 @@ struct TALER_MERCHANTDB_Plugin const char *category_filter, const char *name_filter, const char *description_filter, + uint64_t product_group_id_filter, TALER_MERCHANTDB_ProductsCallback cb, void *cb_cls); diff --git a/src/lib/merchant_api_get-private-products.c b/src/lib/merchant_api_get-private-products.c @@ -15,7 +15,7 @@ <http://www.gnu.org/licenses/> */ /** - * @file merchant_api_get-private-products-new.c + * @file merchant_api_get-private-products.c * @brief Implementation of the GET /private/products request * @author Christian Grothoff */ @@ -262,4 +262,4 @@ TALER_MERCHANT_get_private_products_cancel ( } -/* end of merchant_api_get-private-products-new.c */ +/* end of merchant_api_get-private-products.c */