diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-14 16:48:52 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-14 16:48:52 +0000 |
commit | aa07f4bc9eff2a252743e20faa334f2aa7d589d5 (patch) | |
tree | 177051f9fe263c7b1523aff6f83e8c1675d7d8b0 /src/libserver/task.c | |
parent | 137f4b1e53572d5f43a5a6368482f82149652091 (diff) | |
download | rspamd-aa07f4bc9eff2a252743e20faa334f2aa7d589d5.tar.gz rspamd-aa07f4bc9eff2a252743e20faa334f2aa7d589d5.zip |
[Project] More work towards flexible actions
Diffstat (limited to 'src/libserver/task.c')
-rw-r--r-- | src/libserver/task.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/libserver/task.c b/src/libserver/task.c index eaa379361..df1a561cb 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -26,7 +26,10 @@ #include "utlist.h" #include "contrib/zstd/zstd.h" #include "libserver/mempool_vars_internal.h" +#include "libserver/cfg_file_private.h" #include "libmime/lang_detection.h" +#include "libmime/filter_private.h" + #include <math.h> /* @@ -1072,11 +1075,11 @@ rspamd_task_log_metric_res (struct rspamd_task *task, rspamd_fstring_t *symbuf; struct rspamd_symbol_result *sym; GPtrArray *sorted_symbols; - enum rspamd_action_type act; + struct rspamd_action *act; guint i, j; mres = task->result; - act = rspamd_check_action_metric (task, mres); + act = rspamd_check_action_metric (task); if (mres != NULL) { switch (lf->type) { @@ -1084,7 +1087,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task, if (RSPAMD_TASK_IS_SKIPPED (task)) { res.begin = "S"; } - else if (act == METRIC_ACTION_REJECT) { + else if (!(act->flags & RSPAMD_ACTION_HAM)) { res.begin = "T"; } else { @@ -1094,7 +1097,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task, res.len = 1; break; case RSPAMD_LOG_ACTION: - res.begin = rspamd_action_to_str (act); + res.begin = act->name; res.len = strlen (res.begin); break; case RSPAMD_LOG_SCORES: @@ -1441,14 +1444,17 @@ rspamd_task_log_variable (struct rspamd_task *task, if (!isnan (pr->target_score)) { var.len = rspamd_snprintf (numbuf, sizeof (numbuf), "%s \"%s\"; score=%.2f (set by %s)", - rspamd_action_to_str (pr->action), - pr->message, pr->target_score, pr->module); + pr->action->name, + pr->message, + pr->target_score, + pr->module); } else { var.len = rspamd_snprintf (numbuf, sizeof (numbuf), "%s \"%s\"; score=nan (set by %s)", - rspamd_action_to_str (pr->action), - pr->message, pr->module); + pr->action->name, + pr->message, + pr->module); } var.begin = numbuf; } @@ -1536,7 +1542,7 @@ rspamd_task_write_log (struct rspamd_task *task) gdouble rspamd_task_get_required_score (struct rspamd_task *task, struct rspamd_metric_result *m) { - guint i; + gint i; if (m == NULL) { m = task->result; @@ -1546,9 +1552,9 @@ rspamd_task_get_required_score (struct rspamd_task *task, struct rspamd_metric_r } } - for (i = METRIC_ACTION_REJECT; i < METRIC_ACTION_NOACTION; i ++) { - if (!isnan (m->actions_limits[i])) { - return m->actions_limits[i]; + for (i = m->nactions - 1; i >= 0; i --) { + if (!isnan (m->actions_limits[i].cur_limit)) { + return m->actions_limits[i].cur_limit; } } |