Browse Source

Rework pre-filters results processing.

tags/0.7.1
Vsevolod Stakhov 9 years ago
parent
commit
a59114820e
4 changed files with 13 additions and 2 deletions
  1. 1
    0
      src/libmime/filter.c
  2. 1
    0
      src/libmime/filter.h
  3. 10
    2
      src/libserver/protocol.c
  4. 1
    0
      src/lua/lua_task.c

+ 1
- 0
src/libmime/filter.c View File

@@ -93,6 +93,7 @@ rspamd_create_metric_result (struct rspamd_task *task, const gchar *name)
metric_res->score = 0;
g_hash_table_insert (task->results, (gpointer) metric->name,
metric_res);
metric_res->action = METRIC_ACTION_MAX;

return metric_res;
}

+ 1
- 0
src/libmime/filter.h View File

@@ -65,6 +65,7 @@ struct metric {
struct metric_result {
struct metric *metric; /**< pointer to metric structure */
double score; /**< total score */
enum rspamd_metric_action action; /**< the current action */
GHashTable *symbols; /**< symbols of metric */
gboolean checked; /**< whether metric result is consolidated */
double grow_factor; /**< current grow factor */

+ 10
- 2
src/libserver/protocol.c View File

@@ -648,8 +648,16 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
m = mres->metric;

/* XXX: handle settings */
action = rspamd_check_action_metric (task, mres->score, &required_score, m);
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);

if (task->is_skipped) {
action_char = 'S';
}
@@ -659,6 +667,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
else {
action_char = 'F';
}

rspamd_printf_gstring (logbuf, "(%s: %c (%s): [%.2f/%.2f] [",
m->name, action_char,
rspamd_action_to_str (action),
@@ -790,7 +799,6 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
rspamd_http_message_add_header (msg, hn->str, hv->str);
}


g_hash_table_iter_init (&hiter, task->results);

top = ucl_object_typed_new (UCL_OBJECT);

+ 1
- 0
src/lua/lua_task.c View File

@@ -793,6 +793,7 @@ lua_task_set_pre_result (lua_State * L)
mres = rspamd_create_metric_result (task, DEFAULT_METRIC);
if (mres != NULL) {
mres->score = mres->metric->actions[action].score;
mres->action = action;
}
task->pre_result.action = action;
if (lua_gettop (L) >= 3) {

Loading…
Cancel
Save