]> source.dussan.org Git - rspamd.git/commitdiff
Add method to set task's settings.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Aug 2014 17:29:27 +0000 (18:29 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Aug 2014 17:29:27 +0000 (18:29 +0100)
src/lua/lua_task.c

index fd8942ce64cdd9b0705b56ad581c27688620a43d..2a2c173e14c3ced4458e68ca03e97b8500754cc1 100644 (file)
@@ -92,6 +92,7 @@ LUA_FUNCTION_DEF (task, get_timeval);
 LUA_FUNCTION_DEF (task, get_metric_score);
 LUA_FUNCTION_DEF (task, get_metric_action);
 LUA_FUNCTION_DEF (task, learn);
+LUA_FUNCTION_DEF (task, set_settings);
 
 static const struct luaL_reg tasklib_f[] = {
        LUA_INTERFACE_DEF (task, create_empty),
@@ -143,6 +144,7 @@ static const struct luaL_reg tasklib_m[] = {
        LUA_INTERFACE_DEF (task, get_metric_score),
        LUA_INTERFACE_DEF (task, get_metric_action),
        LUA_INTERFACE_DEF (task, learn),
+       LUA_INTERFACE_DEF (task, set_settings),
        {"__tostring", lua_class_tostring},
        {NULL, NULL}
 };
@@ -1336,6 +1338,20 @@ lua_task_learn (lua_State *L)
        return ret;
 }
 
+static gint
+lua_task_set_settings (lua_State *L)
+{
+       struct rspamd_task *task = lua_check_task (L);
+       ucl_object_t *settings;
+
+       settings = ucl_object_lua_import (L, 2);
+       if (settings != NULL) {
+               task->settings = settings;
+       }
+
+       return 0;
+}
+
 static gint
 lua_task_get_metric_score (lua_State *L)
 {