local output_spam = {}
local output_ham = {}
-local learned_ham = redis.call('HGET', prefix, 'learns_ham') or 0
-local learned_spam = redis.call('HGET', prefix, 'learns_spam') or 0
+local learned_ham = tonumber(redis.call('HGET', prefix, 'learns_ham')) or 0
+local learned_spam = tonumber(redis.call('HGET', prefix, 'learns_spam')) or 0
local prefix_underscore = prefix .. '_'
-- Output is a set of pairs (token_index, token_count), tokens that are not
}
for (auto [idx, val]: *results) {
- tok = (rspamd_token_t *) g_ptr_array_index(tokens, idx);
+ tok = (rspamd_token_t *) g_ptr_array_index(tokens, idx - 1);
tok->values[id] = val;
}
rt->learned = learned;
redis_stat_runtime<float>::result_type *res;
- res = new redis_stat_runtime<float>::result_type(lua_objlen(L, tokens_pos));
+ res = new redis_stat_runtime<float>::result_type();
for (lua_pushnil(L); lua_next(L, tokens_pos); lua_pop(L, 1)) {
lua_rawgeti(L, -1, 1);
filler_func(opposite_rt_maybe.value(), L, lua_tointeger(L, 4), 6);
}
+ /* Mark task as being processed */
+ task->flags |= RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS | RSPAMD_TASK_FLAG_HAS_HAM_TOKENS;
+
/* Process all tokens */
g_assert(rt->tokens != nullptr);
rt->process_tokens(rt->tokens);
if (!rt->need_redis_call) {
/* No need to do anything, as it is already done in the opposite class processing */
+ /* However, we need to store id as it is needed for further tokens processing */
+ rt->id = id;
return TRUE;
}
gsize tokens_len;
gchar *tokens_buf = rspamd_redis_serialize_tokens(task, tokens, &tokens_len);
-
rt->id = id;
lua_pushcfunction(L, &rspamd_lua_traceback);