commit 02234fa: [Minor] autolearn: log some info on the message
Alexander Moisseev
moiseev at mezonplus.ru
Tue Aug 27 09:42:03 UTC 2019
Author: Alexander Moisseev
Date: 2019-08-27 12:11:14 +0300
URL: https://github.com/rspamd/rspamd/commit/02234fac8f4798cf029cb34c63f8f91299a9cf8d (refs/pull/3018/head)
[Minor] autolearn: log some info on the message
---
lualib/lua_bayes_learn.lua | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/lualib/lua_bayes_learn.lua b/lualib/lua_bayes_learn.lua
index 5a46265e7..066e86a4d 100644
--- a/lualib/lua_bayes_learn.lua
+++ b/lualib/lua_bayes_learn.lua
@@ -51,6 +51,30 @@ exports.can_learn = function(task, is_spam, is_unlearn)
end
exports.autolearn = function(task, conf)
+ local function log_can_autolearn(verdict, score, threshold)
+ local from = task:get_from('smtp')
+ local mime_rcpts = 'undef'
+ local mr = task:get_recipients('mime')
+ if mr then
+ for _,r in ipairs(mr) do
+ if mime_rcpts == 'undef' then
+ mime_rcpts = r.addr
+ else
+ mime_rcpts = mime_rcpts .. ',' .. r.addr
+ end
+ end
+ end
+
+ lua_util.debugm(N, task, 'id: %s, from: <%s>: can autolearn %s: score %s %s %s, mime_rcpts: <%s>',
+ task:get_header('Message-Id') or '<undef>',
+ from and from[1].addr or 'undef',
+ verdict,
+ string.format("%.2f", score),
+ verdict == 'ham' and '<=' or verdict == 'spam' and '>=' or '/',
+ threshold,
+ mime_rcpts)
+ end
+
-- We have autolearn config so let's figure out what is requested
local verdict,score = lua_util.get_task_verdict(task)
local learn_spam,learn_ham = false, false
@@ -65,14 +89,12 @@ exports.autolearn = function(task, conf)
if conf.spam_threshold and conf.ham_threshold then
if verdict == 'spam' then
if conf.spam_threshold and score >= conf.spam_threshold then
- lua_util.debugm(N, task, 'can autolearn spam: score %s >= %s',
- score, conf.spam_threshold)
+ log_can_autolearn(verdict, score, conf.spam_threshold)
learn_spam = true
end
elseif verdict == 'ham' then
if conf.ham_threshold and score <= conf.ham_threshold then
- lua_util.debugm(N, task, 'can autolearn ham: score %s <= %s',
- score, conf.ham_threshold)
+ log_can_autolearn(verdict, score, conf.ham_threshold)
learn_ham = true
end
end
More information about the Commits
mailing list