Browse Source

Merge pull request #4930 from aduernberger/bayes_relearn

[Fix] Relearn messages in bayes filter
pull/4934/head
Vsevolod Stakhov 1 week ago
parent
commit
b4b3739074
No account linked to committer's email address

+ 3
- 2
lualib/redis_scripts/bayes_cache_learn.lua View File

@@ -15,7 +15,8 @@ for i = 0, conf.cache_max_keys do
local have = redis.call('HGET', prefix, cache_id)

if have then
-- Already in cache
-- Already in cache, but is_spam changes when relearning
redis.call('HSET', prefix, cache_id, is_spam)
return false
end
end
@@ -58,4 +59,4 @@ if not added then
end
end

return true
return true

+ 2
- 2
lualib/redis_scripts/bayes_learn.lua View File

@@ -26,7 +26,7 @@ redis.call('HSET', prefix, 'version', '2') -- new schema
redis.call('HINCRBY', prefix, learned_key, is_unlearn and -1 or 1) -- increase or decrease learned count

for i, token in ipairs(input_tokens) do
redis.call('HINCRBY', token, hash_key, 1)
redis.call('HINCRBY', token, hash_key, is_unlearn and -1 or 1)
if text_tokens then
local tok1 = text_tokens[i * 2 - 1]
local tok2 = text_tokens[i * 2]
@@ -41,4 +41,4 @@ for i, token in ipairs(input_tokens) do
redis.call('ZINCRBY', prefix .. '_z', is_unlearn and -1 or 1, token)
end
end
end
end

+ 1
- 1
src/libstat/learn_cache/redis_cache.cxx View File

@@ -170,7 +170,7 @@ rspamd_stat_cache_checked(lua_State *L)
(task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM) ? "spam" : "ham");
task->flags |= RSPAMD_TASK_FLAG_ALREADY_LEARNED;
}
else if (val != 0) {
else {
/* Unlearn flag */
task->flags |= RSPAMD_TASK_FLAG_UNLEARN;
}

Loading…
Cancel
Save