From 6deaf1129d3bb8ad8967698e31ac139a35c2e111 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 12 Nov 2016 14:43:04 +0000 Subject: [PATCH] [Feature] Send hashes values to reply --- src/plugins/fuzzy_check.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 803958b81..452374853 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -1954,8 +1954,27 @@ cleanup: rspamd_upstream_ok (session->server); if (session->http_entry) { - rspamd_controller_send_string (session->http_entry, - "{\"success\":true}"); + ucl_object_t *reply, *hashes; + guint i; + gchar hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1]; + + reply = ucl_object_typed_new (UCL_OBJECT); + + ucl_object_insert_key (reply, ucl_object_fromstring ("true"), + "success", 0, false); + hashes = ucl_object_typed_new (UCL_ARRAY); + + for (i = 0; i < session->commands->len; i ++) { + io = g_ptr_array_index (session->commands, i); + + rspamd_snprintf (hexbuf, sizeof (hexbuf), "%*xs", + (gint)sizeof (io->cmd.digest), io->cmd.digest); + ucl_array_append (hashes, ucl_object_fromstring (hexbuf)); + } + + ucl_object_insert_key (reply, hashes, "hashes", 0, false); + rspamd_controller_send_ucl (session->http_entry, reply); + ucl_object_unref (reply); } } -- 2.39.5