diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-01-22 14:18:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-01-22 14:42:05 +0000 |
commit | 66cc2d3d88dc48fbbffc59e64549b0ee1da4bcf4 (patch) | |
tree | ae2cbc182ea116a1150eada9db7c89f3fe582e3a | |
parent | e7b3d77bc47de5e235f320873ac500b4ea8ea71e (diff) | |
download | rspamd-66cc2d3d88dc48fbbffc59e64549b0ee1da4bcf4.tar.gz rspamd-66cc2d3d88dc48fbbffc59e64549b0ee1da4bcf4.zip |
[Fix] Fix storing of the bayes tokens
-rw-r--r-- | lualib/redis_scripts/bayes_learn.lua | 2 | ||||
-rw-r--r-- | src/libstat/backends/redis_backend.cxx | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lualib/redis_scripts/bayes_learn.lua b/lualib/redis_scripts/bayes_learn.lua index bf2775349..80d86d803 100644 --- a/lualib/redis_scripts/bayes_learn.lua +++ b/lualib/redis_scripts/bayes_learn.lua @@ -38,7 +38,7 @@ for i, token in ipairs(input_tokens) do redis.call('HSET', token, 'tokens', tok1) end - redis.call('ZINCRBY', prefix .. '_z', token, is_unlearn and -1 or 1) + redis.call('ZINCRBY', prefix .. '_z', is_unlearn and -1 or 1, token) end end end
\ No newline at end of file diff --git a/src/libstat/backends/redis_backend.cxx b/src/libstat/backends/redis_backend.cxx index 375fa6c9b..4d9429360 100644 --- a/src/libstat/backends/redis_backend.cxx +++ b/src/libstat/backends/redis_backend.cxx @@ -1017,11 +1017,6 @@ rspamd_redis_learn_tokens(struct rspamd_task *task, } lua_new_text(L, tokens_buf, tokens_len, false); - if (text_tokens_len) { - nargs = 9; - lua_new_text(L, text_tokens_buf, text_tokens_len, false); - } - /* Store rt in random cookie */ char *cookie = (char *) rspamd_mempool_alloc(task->task_pool, 16); rspamd_random_hex(cookie, 16); @@ -1031,6 +1026,11 @@ rspamd_redis_learn_tokens(struct rspamd_task *task, lua_pushstring(L, cookie); lua_pushcclosure(L, &rspamd_redis_learned, 1); + if (text_tokens_len) { + nargs = 9; + lua_new_text(L, text_tokens_buf, text_tokens_len, false); + } + if (lua_pcall(L, nargs, 0, err_idx) != 0) { msg_err_task("call to script failed: %s", lua_tostring(L, -1)); lua_settop(L, err_idx - 1); |