commit 1ee62d0d625347116aeed43f6292736a7255cf71
parent 06effe2721d27e30d87440769c1472fcfb834d29
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 30 Mar 2025 14:00:48 +0200
add TALER_TEMPLATING_fill2
Diffstat:
5 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/src/exchange/taler-exchange-sanctionscheck.c b/src/exchange/taler-exchange-sanctionscheck.c
@@ -190,12 +190,16 @@ sanction_cb (void *cls,
new_rules = freeze ? freeze_rules : NULL;
events = freeze ? freeze_event : partial_match_event;
properties = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("sanction_list_best_match",
+ GNUNET_JSON_pack_string ("SANCTION_LIST_BEST_MATCH",
best_match),
- GNUNET_JSON_pack_double ("sanction_list_rating",
+ GNUNET_JSON_pack_double ("SANCTION_LIST_RATING",
rating),
- GNUNET_JSON_pack_double ("sanction_list_confidence",
- confidence));
+ GNUNET_JSON_pack_double ("SANCTION_LIST_CONFIDENCE",
+ confidence),
+ GNUNET_JSON_pack_string ("AML_INVESTIGATION_STATE",
+ "INVESTIGATION_PENDING"),
+ GNUNET_JSON_pack_string ("AML_INVESTIGATION_TIGGER",
+ "SANCTION_LIST_MATCH"));
GNUNET_assert (0 ==
json_object_update_missing (properties,
acc->properties));
diff --git a/src/exchangedb/tops-0001.sql b/src/exchangedb/tops-0001.sql
@@ -175,7 +175,7 @@ BEGIN
my_measure_name = my_old_rules.new_measure_name;
my_rules = my_old_rules.jnew_rules;
my_investigate_property = json_object(ARRAY['AML_INVESTIGATION_STATE',
- 'AML_TRIGGER'],
+ 'AML_INVESTIGATION_TRIGGER'],
ARRAY['INVESTIATION_PENDING',
'DEPOSIT_ANOMALY']);
IF my_properties IS NULL
diff --git a/src/include/taler_templating_lib.h b/src/include/taler_templating_lib.h
@@ -42,6 +42,25 @@ TALER_TEMPLATING_fill (const char *tmpl,
/**
+ * Fill in Mustach template @a tmpl using the data from @a root
+ * and return the result in @a result.
+ *
+ * @param tmpl string with Mustach template, not 0-terminated
+ * @param tmpl_len length of the input in @a tmpl
+ * @param root JSON data to fill into the template
+ * @param[out] result where to write the result
+ * @param[out] result_size where to write the length of the result
+ * @return 0 on success, otherwise Mustach-specific error code
+ */
+int
+TALER_TEMPLATING_fill2 (const void *tmpl,
+ size_t tmpl_len,
+ const json_t *root,
+ void **result,
+ size_t *result_size);
+
+
+/**
* Load a @a template and substitute using @a root, returning the result in a
* @a reply encoded suitable for the @a connection with the given @a
* http_status code. On errors, the @a http_status code
diff --git a/src/templating/Makefile.am b/src/templating/Makefile.am
@@ -40,7 +40,7 @@ libtalertemplating_la_LIBADD = \
-ljansson \
$(XLIB)
libtalertemplating_la_LDFLAGS = \
- -version-info 0:0:0 \
+ -version-info 1:0:1 \
-no-undefined
libtalertemplating_la_CFLAGS = \
-DMUSTACH_SAFE=1 \
diff --git a/src/templating/templating_api.c b/src/templating/templating_api.c
@@ -203,6 +203,34 @@ TALER_TEMPLATING_fill (const char *tmpl,
}
+int
+TALER_TEMPLATING_fill2 (const void *tmpl,
+ size_t tmpl_len,
+ const json_t *root,
+ void **result,
+ size_t *result_size)
+{
+ int eno;
+
+ if (0 !=
+ (eno = mustach_jansson_mem (tmpl,
+ tmpl_len,
+ (json_t *) root,
+ Mustach_With_AllExtensions,
+ (char **) result,
+ result_size)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "mustach failed on template with error %d\n",
+ eno);
+ *result = NULL;
+ *result_size = 0;
+ return eno;
+ }
+ return eno;
+}
+
+
enum GNUNET_GenericReturnValue
TALER_TEMPLATING_build (struct MHD_Connection *connection,
unsigned int *http_status,