From: Vsevolod Stakhov Date: Tue, 19 Aug 2014 13:10:23 +0000 (+0100) Subject: Process settings in rspamd. X-Git-Tag: 0.7.0~140 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a4cde432d8cf9ac5f4f2eaf49a7dcbecd4f14be8;p=rspamd.git Process settings in rspamd. --- diff --git a/src/libmime/filter.c b/src/libmime/filter.c index f340b9dbc..c8273ed65 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -73,6 +73,7 @@ insert_metric_result (struct rspamd_task *task, struct metric_result *metric_res; struct symbol *s; gdouble *weight, w; + const ucl_object_t *mobj, *sobj; metric_res = g_hash_table_lookup (task->results, metric->name); @@ -102,6 +103,20 @@ insert_metric_result (struct rspamd_task *task, w = (*weight) * flag; } + if (task->settings) { + mobj = ucl_object_find_key (task->settings, metric->name); + if (mobj) { + gdouble corr; + + sobj = ucl_object_find_key (mobj, symbol); + if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) { + msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f", + symbol, w, corr); + w = corr * flag; + } + } + } + /* Add metric score */ if ((s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) { if (s->options && opts && opts != s->options) { @@ -320,6 +335,17 @@ process_filters (struct rspamd_task *task) struct metric *metric; gpointer item = NULL; + if (task->settings) { + const ucl_object_t *wl; + + wl = ucl_object_find_key (task->settings, "whitelist"); + if (wl != NULL) { + msg_info ("<%s> is whitelisted", task->message_id); + task->is_skipped = TRUE; + return 0; + } + } + /* Process metrics symbols */ while (call_symbol_callback (task, task->cfg->cache, &item)) { /* Check reject actions */