[Fix] Relearn messages in bayes filterpull/4934/head
@@ -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 |
@@ -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 |
@@ -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; | |||
} |