From 09e125bdc94c80b0582155d45b055fa84627e20d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 25 Aug 2015 18:14:36 +0100 Subject: [PATCH] Fix settings for actions other than reject --- src/libmime/filter.c | 6 +++++- src/libserver/cfg_utils.c | 1 + src/libserver/protocol.c | 10 ++-------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 4d8e15e48..c24f42f35 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -372,13 +372,17 @@ get_specific_action_score (const ucl_object_t *metric, struct metric_action *action) { const ucl_object_t *act, *sact; + const gchar *act_name; double score; if (metric) { act = ucl_object_find_key (metric, "actions"); if (act) { - sact = ucl_object_find_key (act, rspamd_action_to_str (action->action)); + act_name = rspamd_action_to_str (action->action); + sact = ucl_object_find_key (act, act_name); if (sact != NULL && ucl_object_todouble_safe (sact, &score)) { + msg_debug ("found override score %.2f for action %s in settings", + score, act_name); return score; } } diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index ecdd28a91..7246ab4a1 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -552,6 +552,7 @@ rspamd_config_new_metric (struct rspamd_config *cfg, struct metric *c, for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i++) { c->actions[i].score = -1.0; + c->actions[i].action = i; } c->subject = SPAM_SUBJECT; diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 162f75f40..3ee2def4d 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -866,15 +866,9 @@ rspamd_metric_result_ucl (struct rspamd_task *task, gchar action_char; m = mres->metric; + mres->action = rspamd_check_action_metric (task, mres->score, + &required_score, m); - /* XXX: handle settings */ - if (mres->action == METRIC_ACTION_MAX) { - mres->action = rspamd_check_action_metric (task, mres->score, - &required_score, m); - } - else { - required_score = mres->metric->actions[mres->action].score; - } action = mres->action; is_spam = (action == METRIC_ACTION_REJECT); -- 2.39.5