aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-30 16:41:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-30 16:41:48 +0100
commitf8ba14329f3389d24fde83f71beb02e7e902d901 (patch)
tree5af8f972e82979d3c118f247d5b47621de712362
parent89519495ee207056ed469f0231d089583c366dd8 (diff)
downloadrspamd-f8ba14329f3389d24fde83f71beb02e7e902d901.tar.gz
rspamd-f8ba14329f3389d24fde83f71beb02e7e902d901.zip
[Minor] Allow to insert enforced results from Lua
-rw-r--r--src/lua/lua_task.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index dbd0dcd9b..17aee10b8 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1247,20 +1247,32 @@ lua_task_insert_result (lua_State * L)
{
struct rspamd_task *task = lua_check_task (L, 1);
const gchar *symbol_name, *param;
- double flag;
+ double weight;
struct rspamd_symbol_result *s;
- gint i, top;
+ enum rspamd_symbol_insert_flags flags = RSPAMD_SYMBOL_INSERT_DEFAULT;
+ gint i, top, args_start;
if (task != NULL) {
- symbol_name =
- rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 2));
- flag = luaL_checknumber (L, 3);
+ if (lua_isboolean (L, 2)) {
+ args_start = 3;
+
+ if (lua_toboolean (L, 2)) {
+ flags |= RSPAMD_SYMBOL_INSERT_ENFORCE;
+ }
+ }
+ else {
+ args_start = 2;
+ }
+
+ symbol_name = rspamd_mempool_strdup (task->task_pool,
+ luaL_checkstring (L, args_start));
+ weight = luaL_checknumber (L, args_start + 1);
top = lua_gettop (L);
- s = rspamd_task_insert_result (task, symbol_name, flag, NULL);
+ s = rspamd_task_insert_result_full (task, symbol_name, weight, NULL, flags);
/* Get additional options */
if (s) {
- for (i = 4; i <= top; i++) {
+ for (i = args_start + 2; i <= top; i++) {
if (lua_type (L, i) == LUA_TSTRING) {
param = luaL_checkstring (L, i);
rspamd_task_add_result_option (task, s, param);