diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-28 12:29:43 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-06-28 12:29:43 +0100 |
commit | d69aea948b25168bc6d0240009952b1e1ee32bc8 (patch) | |
tree | 9ab5f57cb9f383696e8fd8b874f27d3d5c508bf4 | |
parent | 40b1540465e1f666d0b69ecd4000cae706f05ba2 (diff) | |
download | rspamd-d69aea948b25168bc6d0240009952b1e1ee32bc8.tar.gz rspamd-d69aea948b25168bc6d0240009952b1e1ee32bc8.zip |
[Feature] Allow to change flag from fuzzy learn condition
-rw-r--r-- | src/plugins/fuzzy_check.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index f775e9e09..bda4a12bc 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -2348,17 +2348,28 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent, *ptask = task; rspamd_lua_setclass (L, "rspamd{task}", -1); - if (lua_pcall (L, 1, 1, err_idx) != 0) { + if (lua_pcall (L, 1, LUA_MULTRET, err_idx) != 0) { tb = lua_touserdata (L, -1); msg_err_task ("call to user extraction script failed: %v", tb); g_string_free (tb, TRUE); } else { - skip = !(lua_toboolean (L, -1)); + if (lua_gettop (L) > 1) { + skip = !(lua_toboolean (L, -2)); + + if (lua_isnumber (L, -1)) { + msg_info_task ("learn condition changed flag from %d to " + "%d", flag, (guint)lua_tonumber (L, -1)); + flag = lua_tonumber (L, -1); + } + } + else { + skip = !(lua_toboolean (L, -1)); + } } /* Result + error function */ - lua_pop (L, 2); + lua_settop (L, 0); if (skip) { msg_info_task ("skip rule %s as its condition callback returned" |