commit 6b1be1e: [Feature] Add description to the groups

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Aug 12 12:56:07 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-12 13:48:33 +0100
URL: https://github.com/rspamd/rspamd/commit/6b1be1eb125756d77b64b249af5739e6e52644ed

[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;
 }
 


More information about the Commits mailing list