]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix one shot mode for SA metas
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 8 Feb 2016 11:30:12 +0000 (11:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 8 Feb 2016 11:30:12 +0000 (11:30 +0000)
src/lua/lua_config.c
src/plugins/lua/spamassassin.lua

index bd1f5852fd7c87d195aadbdb070296975dfff7b7..fa778ff6d7b23eb6087a32c881f4fa5aeb3ccd96 100644 (file)
@@ -940,7 +940,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
 
                if (nresults >= 1) {
                        /* Function returned boolean, so maybe we need to insert result? */
-                       gint res;
+                       gint res = 0;
                        GList *opts = NULL;
                        gint i;
                        gdouble flag = 1.0;
index d7406612445f5ec22a5fcee2cb1e433fdbc1f7d7..4f41681e6e16e1786b7267ebffcc073a9e99fe74 100644 (file)
@@ -1212,6 +1212,7 @@ local function post_process()
             res = expression:process(task)
           end
           if res > 0 then
+            -- Symbol should be one shot to make it working properly
             task:insert_result(k, res)
           end
         else
@@ -1226,7 +1227,10 @@ local function post_process()
         rspamd_logger.errx(rspamd_config, 'Cannot parse expression ' .. r['meta'])
       else
         if r['score'] then
-          rspamd_config:set_metric_symbol(k, r['score'], r['description'])
+          rspamd_config:set_metric_symbol({
+            name = k, score = r['score'],
+            description = r['description'],
+            one_shot = true })
         end
         rspamd_config:register_symbol(k, calculate_score(k, r), meta_cb)
         r['expression'] = expression