]> source.dussan.org Git - rspamd.git/commitdiff
Rework pre-filters results processing.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Sep 2014 15:51:05 +0000 (16:51 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Sep 2014 15:51:05 +0000 (16:51 +0100)
src/libmime/filter.c
src/libmime/filter.h
src/libserver/protocol.c
src/lua/lua_task.c

index 6ae51f76975e33505c9fa4e0f381fa30d0ab778c..540502a47152cab5d6e98dd8cf9cf61f10c99cb1 100644 (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;
 }
index 69c20bdd1f7c5e85cc28eaa4cbd94e79dede3e81..3f01f2314390e946b41f20d6f40741684c22655a 100644 (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                                        */
index 9ecb3c64215fc141c015f693dd9dbe3ef6b27295..7dadc65ec5b0af331fd68527dcf0004c623f564d 100644 (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);
index d91774d1b122b26168831c6ce0056b0811c0c01d..cb0d7325bc10dd67b8a6ff5cc8d92825416a8f1b 100644 (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) {