commit c8452b0: [Rework] Breaking: Do not report module as action

Alexander Moisseev moiseev at mezonplus.ru
Mon Jul 29 17:51:58 UTC 2024


Author: Alexander Moisseev
Date: 2024-01-28 11:25:10 +0300
URL: https://github.com/rspamd/rspamd/commit/c8452b009d07a055208e92602c43bcf2143acde2 (refs/pull/4795/head)

[Rework] Breaking: Do not report module as action
in the /history response since we have the `passthrough_module` key
for that purpose.

While that might be handy in some situations,
mixing actions and module names is confusing in general.

---
 lualib/lua_verdict.lua            | 21 +--------------------
 src/plugins/lua/history_redis.lua |  3 +--
 2 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/lualib/lua_verdict.lua b/lualib/lua_verdict.lua
index 6ce99e660..4c9880b85 100644
--- a/lualib/lua_verdict.lua
+++ b/lualib/lua_verdict.lua
@@ -186,23 +186,4 @@ exports.describe = function(verdict, what)
   return nil
 end
 
----[[[
--- @function lua_verdict.adjust_passthrough_action(task)
--- If an action is `soft reject` then this function extracts a module that has set this action
--- and returns an adjusted action (e.g. 'greylist' or 'ratelimit').
--- Otherwise an action is returned as is.
---]]
-exports.adjust_passthrough_action = function(task)
-  local action = task:get_metric_action()
-  if action == 'soft reject' then
-    local has_pr, _, _, module = task:has_pre_result()
-
-    if has_pr and module then
-      action = module
-    end
-  end
-
-  return action
-end
-
-return exports
\ No newline at end of file
+return exports
diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua
index d0aa5aec7..a5f4ec854 100644
--- a/src/plugins/lua/history_redis.lua
+++ b/src/plugins/lua/history_redis.lua
@@ -47,7 +47,6 @@ local lua_redis = require "lua_redis"
 local fun = require "fun"
 local ucl = require "ucl"
 local ts = (require "tableshape").types
-local lua_verdict = require "lua_verdict"
 local E = {}
 local N = "history_redis"
 local hostname = rspamd_util.get_hostname()
@@ -115,7 +114,7 @@ local function normalise_results(tbl, task)
   tbl.rmilter = nil
   tbl.messages = nil
   tbl.urls = nil
-  tbl.action = lua_verdict.adjust_passthrough_action(task)
+  tbl.action = task:get_metric_action()
 
   local seconds = task:get_timeval()['tv_sec']
   tbl.unix_time = seconds


More information about the Commits mailing list