diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-04 15:18:50 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-04 15:18:50 +0000 |
commit | 9f754e6c7738f2d0b136c07bf4ac8060888cb3b4 (patch) | |
tree | 6fa9aa990b876942656a8963f950ba7817cfab5a /lualib | |
parent | 7a719d343eea81b0b8cbb8b24e7908b80d1f9a59 (diff) | |
download | rspamd-9f754e6c7738f2d0b136c07bf4ac8060888cb3b4.tar.gz rspamd-9f754e6c7738f2d0b136c07bf4ac8060888cb3b4.zip |
[Project] Temporary fixes to start new bayes logic debug
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_bayes_redis.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lualib/lua_bayes_redis.lua b/lualib/lua_bayes_redis.lua index 27d6c3e6f..5dca2db43 100644 --- a/lualib/lua_bayes_redis.lua +++ b/lualib/lua_bayes_redis.lua @@ -19,15 +19,30 @@ limitations under the License. local exports = {} local lua_redis = require "lua_redis" local logger = require "rspamd_logger" +local lua_util = require "lua_util" + +local N = "stat_redis" local function gen_classify_functor(redis_params, classify_script_id) - return function(task, expanded_key, stat_tokens) - -- TODO: write this function + return function(task, expanded_key, id, is_spam, stat_tokens, callback) + + local function classify_redis_cb(err, data) + lua_util.debugm(N, task, 'classify redis cb: %s, %s', err, data) + if err then + callback(task, false, err) + else + callback(task, true, data[1], data[2], data[3]) + end + end + + lua_redis.exec_redis_script(classify_script_id, + { task = task, is_write = false, key = expanded_key }, + classify_redis_cb, { expanded_key, stat_tokens }) end end local function gen_learn_functor(redis_params, learn_script_id) - return function(task, expanded_key, stat_tokens) + return function(task, expanded_key, id, is_spam, stat_tokens, callback) -- TODO: write this function end end |