aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/force_actions.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-02 18:22:23 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-08-02 18:22:23 +0100
commit64c4be01551d970c281c0e79c54ea16b972348d7 (patch)
tree887442b3b392f620e01e9dd1385f846af64e9205 /src/plugins/lua/force_actions.lua
parentd65d82f84b7045de77e4cf26cc34b4f6d9e9d8e6 (diff)
downloadrspamd-64c4be01551d970c281c0e79c54ea16b972348d7.tar.gz
rspamd-64c4be01551d970c281c0e79c54ea16b972348d7.zip
[Feature] Add ability to match score in force_actions module
Diffstat (limited to 'src/plugins/lua/force_actions.lua')
-rw-r--r--src/plugins/lua/force_actions.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua
index 88b09dfad..d2806d1f7 100644
--- a/src/plugins/lua/force_actions.lua
+++ b/src/plugins/lua/force_actions.lua
@@ -29,7 +29,7 @@ local rspamd_cryptobox_hash = require "rspamd_cryptobox_hash"
local rspamd_expression = require "rspamd_expression"
local rspamd_logger = require "rspamd_logger"
-local function gen_cb(expr, act, pool, message, subject, raction, honor)
+local function gen_cb(expr, act, pool, message, subject, raction, honor, limit)
local function parse_atom(str)
local atom = table.concat(fun.totable(fun.take_while(function(c)
@@ -44,7 +44,8 @@ local function gen_cb(expr, act, pool, message, subject, raction, honor)
local function process_atom(atom, task)
local f_ret = task:has_symbol(atom)
if f_ret then
- return 1
+ f_ret = task:get_symbol(atom)[1].score
+ return f_ret
end
return 0
end
@@ -67,7 +68,8 @@ local function gen_cb(expr, act, pool, message, subject, raction, honor)
return false
end
- if e:process(task) == 1 then
+ local ret = e:process(task)
+ if ret > limit then
if subject then
task:set_metric_subject(subject)
end
@@ -146,9 +148,11 @@ local function configure_module()
if action and expr then
local subject = sett.subject
local message = sett.message
+ local lim = sett.limit or 0
local raction = list_to_hash(sett.require_action)
local honor = list_to_hash(sett.honor_action)
- local cb, atoms = gen_cb(expr, action, rspamd_config:get_mempool(), message, subject, raction, honor)
+ local cb, atoms = gen_cb(expr, action, rspamd_config:get_mempool(),
+ message, subject, raction, honor, lim)
if cb and atoms then
local t = {}
if (raction or honor) then