summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-12 13:48:33 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-12 13:48:33 +0100
commit6b1be1eb125756d77b64b249af5739e6e52644ed (patch)
tree1a04dfe305c9467818f9fbdecdab769384790314
parente2600fef6aac4e838871783e41ab934ab43e2e5b (diff)
downloadrspamd-6b1be1eb125756d77b64b249af5739e6e52644ed.tar.gz
rspamd-6b1be1eb125756d77b64b249af5739e6e52644ed.zip
[Feature] Add description to the groups
Issue: #2985
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_rcl.c9
-rw-r--r--src/libserver/protocol.c5
3 files changed, 15 insertions, 0 deletions
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;
}