]> source.dussan.org Git - rspamd.git/commitdiff
Process settings in rspamd.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 Aug 2014 13:10:23 +0000 (14:10 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 Aug 2014 13:10:23 +0000 (14:10 +0100)
src/libmime/filter.c

index f340b9dbc175d619eee7a7526c37c1ddf45bfb59..c8273ed651b28f775c747576848c03d567fe38c6 100644 (file)
@@ -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 */