]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Send hashes values to reply
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 12 Nov 2016 14:43:04 +0000 (14:43 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 12 Nov 2016 14:43:04 +0000 (14:43 +0000)
src/plugins/fuzzy_check.c

index 803958b81a1aa4f5f768ffa4c8941418759adaff..452374853ec81c82a864de683aeda9532c4ecaec 100644 (file)
@@ -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);
                }
        }