commit c9a2191: [Minor] Return score with verdict

Vsevolod Stakhov vsevolod at highsecure.ru
Tue May 14 18:21:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-05-14 19:15:09 +0100
URL: https://github.com/rspamd/rspamd/commit/c9a2191527bb0b020b04c0e19e6d16b576161f0b

[Minor] Return score with verdict

---
 lualib/lua_util.lua | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index 27df2c72e..3e443bce3 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -895,7 +895,7 @@ exports.add_debug_alias = function(mod, alias)
 end
 ---[[[
 -- @function lua_util.get_task_verdict(task)
--- Returns verdict for a task, must be called from idempotent filters only
+-- Returns verdict for a task + score if certain, must be called from idempotent filters only
 -- Returns string:
 -- * `spam`: if message have over reject threshold and has more than one positive rule
 -- * `junk`: if a message has between score between [add_header/rewrite subject] to reject thresholds and has more than two positive rules
@@ -909,28 +909,30 @@ exports.get_task_verdict = function(task)
   if result then
 
     if result.passthrough then
-      return 'passthrough'
+      return 'passthrough',nil
     end
 
+    local score = result.score
+
     local action = result.action
 
     if action == 'reject' and result.npositive > 1 then
-      return 'spam'
+      return 'spam',score
     elseif action == 'no action' then
-      if result.score < 0 or result.nnegative > 3 then
-        return 'ham'
+      if score < 0 or result.nnegative > 3 then
+        return 'ham',score
       end
     else
       -- All colors of junk
       if action == 'add header' or action == 'rewrite subject' then
         if result.npositive > 2 then
-          return 'junk'
+          return 'junk',score
         end
       end
     end
-  end
 
-  return 'uncertain'
+    return 'uncertain',score
+  end
 end
 
 ---[[[


More information about the Commits mailing list