]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Some more minor fixes to lua
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 29 Jul 2017 15:22:46 +0000 (16:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 29 Jul 2017 15:22:46 +0000 (16:22 +0100)
rules/headers_checks.lua
src/plugins/lua/fann_redis.lua

index 2e4bae3073f52fdb56f7c709f8e1971b240fabb8..25cb263ff8de9ed804b30b4fca31fb4eb2bcad43 100644 (file)
@@ -920,15 +920,12 @@ rspamd_config.CTYPE_MIXED_BOGUS = {
     local found = false
     -- Check each part and look for a part that isn't multipart/* or text/plain or text/html
     for _,p in ipairs(parts) do
-      local ct = p:get_header('Content-Type')
-      if (ct) then
-        ct = ct:lower()
-        if (ct:match('^multipart/') or 
-            ct:match('^text/plain') or 
-            ct:match('^text/html')) 
-        then
-          -- Nothing
-        else
+      local pct = p:get_header('Content-Type')
+      if (pct) then
+        pct = pct:lower()
+        if not ((pct:match('^multipart/') or
+            pct:match('^text/plain') or
+            pct:match('^text/html'))) then
           found = true
         end
       end
index ee73a5bf9dd16a0e93b6e0dff3f4edacb00bd965..378000a24c8d44f5db383eaeba0af689b02e0f1c 100644 (file)
@@ -423,18 +423,19 @@ local function load_or_invalidate_fann(data, id, ev_base)
   end
 end
 
-local function fann_train_callback(task, score, required_score, id, opts)
+local function fann_train_callback(task, score, required_score, id)
+  local train_opts = opts['train']
   local fname,suffix = gen_fann_prefix(id)
 
   local learn_spam, learn_ham
 
-  if opts['spam_score'] then
-    learn_spam = score >= opts['spam_score']
+  if train_opts['spam_score'] then
+    learn_spam = score >= train_opts['spam_score']
   else
     learn_spam = score >= required_score
   end
-  if opts['ham_score'] then
-    learn_ham = score <= opts['ham_score']
+  if train_opts['ham_score'] then
+    learn_ham = score <= train_opts['ham_score']
   else
     learn_ham = score < 0
   end
@@ -469,7 +470,7 @@ local function fann_train_callback(task, score, required_score, id, opts)
         if err then
           rspamd_logger.errx(rspamd_config, 'cannot check if we can train %s: %s', fname, err)
           if string.match(err, 'NOSCRIPT') then
-            load_scripts(rspamd_config, ev_base, nil)
+            load_scripts(rspamd_config, task:get_ev_base(), nil)
           end
         end
       end
@@ -836,11 +837,9 @@ local function ann_push_vector(task)
   local scores = task:get_metric_score()
   local sid = task:get_settings_id()
   if use_settings then
-    fann_train_callback(task, scores[1], scores[2],
-      tostring(sid), opts['train'])
+    fann_train_callback(task, scores[1], scores[2], tostring(sid))
   else
-    fann_train_callback(task, scores[1], scores[2],
-      tostring(sid), opts['train'])
+    fann_train_callback(task, scores[1], scores[2], "1")
   end
 end