From 6b1be1eb125756d77b64b249af5739e6e52644ed Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 12 Aug 2019 13:48:33 +0100 Subject: [PATCH] [Feature] Add description to the groups Issue: #2985 --- src/libserver/cfg_file.h | 1 + src/libserver/cfg_rcl.c | 9 +++++++++ src/libserver/protocol.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 3c0df0319..d4855e032 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -117,6 +117,7 @@ enum rspamd_symbol_group_flags { struct rspamd_symbol; struct rspamd_symbols_group { gchar *name; + gchar *description; GHashTable *symbols; gdouble max_score; enum rspamd_symbol_group_flags flags; diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 5b67a5f61..ba1b614a0 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -329,6 +329,7 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, const ucl_object_t *val, *elt; struct rspamd_rcl_section *subsection; struct rspamd_rcl_symbol_data sd; + const gchar *description = NULL; g_assert (key != NULL); @@ -388,6 +389,14 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj, } } + elt = ucl_object_lookup (obj, "description"); + if (elt) { + description = ucl_object_tostring (elt); + + gr->description = rspamd_mempool_strdup (cfg->cfg_pool, + description); + } + sd.gr = gr; sd.cfg = cfg; diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index a51cbf17f..3f07926be 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -1136,6 +1136,11 @@ rspamd_metric_group_ucl (struct rspamd_task *task, ucl_object_insert_key (obj, ucl_object_fromdouble (score), "score", 0, false); + if (gr->description) { + ucl_object_insert_key (obj, ucl_object_fromstring (gr->description), + "description", 0, false); + } + return obj; } -- 2.39.5