aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-23 16:45:29 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-11-23 16:45:29 +0000
commitcd18bb01870f5c1d63e249941f84170112975abf (patch)
tree1f069584ea901369e9a2b95a2c92b4e66f3c8be9 /src/plugins
parent43a821c91c670d5f88436cdb11db87ea3b271ff6 (diff)
downloadrspamd-cd18bb01870f5c1d63e249941f84170112975abf.tar.gz
rspamd-cd18bb01870f5c1d63e249941f84170112975abf.zip
[Minor] Fix configuring logic for bayes_expiry
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/bayes_expiry.lua33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua
index de26e92e1..643ff29c6 100644
--- a/src/plugins/lua/bayes_expiry.lua
+++ b/src/plugins/lua/bayes_expiry.lua
@@ -50,13 +50,13 @@ local function check_redis_classifier(cls, cfg)
if cls.lazy then settings.lazy = cls.lazy end
-- Load symbols from statfiles
- local statfiles = cls.statfile
- for _,stf in ipairs(statfiles) do
- local symbol = stf.symbol or 'undefined'
+
+ local function check_statfile_table(tbl, def_sym)
+ local symbol = tbl.symbol or def_sym
local spam
- if stf.spam then
- spam = stf.spam
+ if tbl.spam then
+ spam = tbl.spam
else
if string.match(symbol:upper(), 'SPAM') then
spam = true
@@ -72,7 +72,27 @@ local function check_redis_classifier(cls, cfg)
end
end
+ local statfiles = cls.statfile
+ if statfiles[1] then
+ for _,stf in ipairs(statfiles) do
+ if not stf.symbol then
+ for k,v in pairs(stf) do
+ check_statfile_table(v, k)
+ end
+ else
+ check_statfile_table(stf, 'undefined')
+ end
+ end
+ else
+ for stn,stf in pairs(statfiles) do
+ check_statfile_table(stf, stn)
+ end
+ end
+
if not symbol_spam or not symbol_ham or type(expiry) ~= 'number' then
+ logger.debugm(N, rspamd_config,
+ 'disable expiry for classifier %s: no expiry %s',
+ symbol_spam, cls)
return
end
-- Now try to load redis_params if needed
@@ -92,6 +112,9 @@ local function check_redis_classifier(cls, cfg)
return
end
+ logger.debugm(N, rspamd_config, "enabled expiry for %s/%s -> %s expiry",
+ symbol_spam, symbol_ham, expiry)
+
table.insert(settings.classifiers, {
symbol_spam = symbol_spam,
symbol_ham = symbol_ham,